From patchwork Thu Jun 13 14:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804121 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA7B142E73; Thu, 13 Jun 2024 14:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287821; cv=none; b=KN+07GmtVFm29AuBp40XgkEd5NXf8ZAVjMZKruG7XAbzldIicZK0nLHfNvYxQHQYoaCD4reUZx6pGrenNHi4g+v4W/iEbPjdCRZGQT81g0RUoRjJtGPyCwEX2Bm4hGu1T4z2Uo4dszuGGt6/sKXup51F5Ofm79Kw4IeXXiXJyQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287821; c=relaxed/simple; bh=kfbDOTov0/7uKDAmdCfshJARzEdStSiJq1qjZfUJEvI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WnsgQHBcBx71HbpysGHC/eHICsdLvqo+Mua5t8NP/b8bYS0Y5sgPz1oXCbM/lTUnNnKP6Km2I05f8ymeU/NH5RZkdYGQXTSlLCIHBhpv+Iu6xZW1EkbZqR3shbW40dTbBnh35xSDxaXs1EfazXYcZ6Nme0wS//UszJdaZ4xJ6G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=VmFJEbaV; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VmFJEbaV" Received: by mail.gandi.net (Postfix) with ESMTPSA id D9AE41BF211; Thu, 13 Jun 2024 14:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CJ/8Ln8PiAlnF/RNZphdxqw6/7DeJ5l7lzf3rL7r59s=; b=VmFJEbaVkjgUtVGCNpij8d+BhEpJDDRps6/9iul5OKTCS1fcbH4sothWfZK6PcpnOx27A9 9ogIujCO5q7tzcLvNqo0PKQ2Zkz9n1cVLotxehykx/yl1TOMb+Anwj6bVwe2F0Lxi9/CCF sUMFT8AEKN7tFSHuQML/05WmHr6kiHBmE3nWF7eFQPG5eZwIzWmxaQI+zu1AMlsJKnupio TvlnobClnh0lUHAcIrn1k54sLYuljWw9F2aMfJBMValmBZ5WQV+doh/TR0QPFETaYYiPUW RCzRLomv5cTJf+jAKR0zTHh2aJUS5oyE3tmXxSYp154ae7PQi+Ut4YSdbOXt6Q== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:40 +0200 Subject: [PATCH 1/6] wifi: wilc1000: disable power sequencer Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-1-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com From: Ajay Singh Driver systematically disables some power mechanism each time it starts the chip firmware (so mostly when interface is brought up). This has a negative impact on some specific scenarios when the chip is exposed as a hotpluggable SDIO card (eg: WILC1000 SD): - when executing suspend/resume sequence while interface has been brought up - rebooting the platform while module is plugged and interface has been brought up Those scenarios lead to mmc core trying to initialize again the chip which is now unresponsive (because of the power sequencer setting), so it fails in mmc_rescan->mmc_attach_sdio and enter a failure loop while trying to send CMD5: mmc0: error -110 whilst initialising SDIO card mmc0: error -110 whilst initialising SDIO card mmc0: error -110 whilst initialising SDIO card [...] Preventing the driver from disabling this "power sequencer" fixes those enumeration issues without affecting nominal operations. Signed-off-by: Ajay Singh Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 15 --------------- drivers/net/wireless/microchip/wilc1000/wlan.h | 1 - 2 files changed, 16 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index e6e20c86b791..6461a3ec0120 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -907,27 +907,12 @@ static int wilc_sdio_sync_ext(struct wilc *wilc, int nint) { struct sdio_func *func = dev_to_sdio_func(wilc->dev); struct wilc_sdio *sdio_priv = wilc->bus_data; - u32 reg; if (nint > MAX_NUM_INT) { dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); return -EINVAL; } - /** - * Disable power sequencer - **/ - if (wilc_sdio_read_reg(wilc, WILC_MISC, ®)) { - dev_err(&func->dev, "Failed read misc reg...\n"); - return -EINVAL; - } - - reg &= ~BIT(8); - if (wilc_sdio_write_reg(wilc, WILC_MISC, reg)) { - dev_err(&func->dev, "Failed write misc reg...\n"); - return -EINVAL; - } - if (sdio_priv->irq_gpio) { u32 reg; int ret, i; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index d72a0a81bbda..dd2fb3c2f06a 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -56,7 +56,6 @@ #define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) #define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) #define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) -#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) #define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) #define WILC_INTR_ENABLE WILC_INTR_REG_BASE #define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) From patchwork Thu Jun 13 14:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804790 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DBB11448D7; Thu, 13 Jun 2024 14:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287821; cv=none; b=CZ+6ypLyxU7aAONwd9KM+LQcLTNRe8mSQ1gDJhxhWxdeIPGMr5nchK7rnaVan1Sy9bMH5JvH4mGrx8vqcKRTvdMw2zszbp8Gt069x7NWyX+aYozmQ6+SsZFwvjNfQl8cCdQUC0gZgGnSan/GWcVYdUJ/h7c4o8a4fgVdIxK9K4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287821; c=relaxed/simple; bh=EunqTQzqUJ/F3JjE+G+C/6XlPd3N6vJCY/SP3DH8r0I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WDhZRB3j4Be4X1Lr2v/0DBodIAUjhO4OL6DhI0gBim001MbUjfYQc+nokvJaRHRARu5yjq83kunjfWvGxTZvh1vtwDBVNkLWGk8jmHvNT6G/51n2tNjlopBb0AruI9wgyGVmxHVNjLKfoixAqHbnK+wICYc/72+vurS4us+UNOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=baV8suq5; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="baV8suq5" Received: by mail.gandi.net (Postfix) with ESMTPSA id 432301BF213; Thu, 13 Jun 2024 14:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C+8CGh8peOxYqhyLXUs4A1Iy7daW4jSk3Jb9aFviGrI=; b=baV8suq5UfSJ8byMycRDYXiJEWCNgKschAdtStX9cmHOyVQ7go0km0aomrOqboJ9bO7Ctu X6Tb2HeB1RGCXsr5Kmo4rQvK3gH05XY8kXJ7sI/yLrLk2qPamtMJfWSQdQ85lrAH4ybNZ+ Z+516AUehwZjqcNTpA8GR0Nmr6h4RTn6UbvJL1fed1hFYfN9gdBXIEIKnKCXokqpIhEOk3 1c5UCwm5cNZAo6gzj36xwDUuCYzjYMITs6msoHSOYLFLMtAptAD6tWEYDrPYQhYYo84Ux2 JhlvRM8OArrxFTvcpPzFrpRA756AqGxbeyyyGlLPjdFh6i9W1v3097K0yTxm3Q== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:41 +0200 Subject: [PATCH 2/6] wifi: wilc1000: let host->chip suspend/resume notifications manage chip wake/sleep Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-2-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com host_wakeup_notify and host_sleep_notify are surrounded by chip_wakeup and chip_allow_sleep calls, which theorically need to be protected with the hif_cs lock. This lock protection is currently missing. Instead of adding the lock where those two functions are called, move those in host->chip suspend notifications to benefit from the lock already used there (in bus_acquire/bus_release) Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 5 ----- drivers/net/wireless/microchip/wilc1000/wlan.c | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 6461a3ec0120..4e478a2cd4cc 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -256,14 +256,12 @@ static int wilc_sdio_suspend(struct device *dev) int ret; dev_info(dev, "sdio suspend\n"); - chip_wakeup(wilc); if (!IS_ERR(wilc->rtc_clk)) clk_disable_unprepare(wilc->rtc_clk); if (wilc->suspend_event) { host_sleep_notify(wilc); - chip_allow_sleep(wilc); } ret = wilc_sdio_reset(wilc); @@ -1003,14 +1001,11 @@ static int wilc_sdio_resume(struct device *dev) dev_info(dev, "sdio resume\n"); sdio_release_host(func); - chip_wakeup(wilc); wilc_sdio_init(wilc, true); if (wilc->suspend_event) host_wakeup_notify(wilc); - chip_allow_sleep(wilc); - return 0; } diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 41a5c0ed7480..533939e71534 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -678,17 +678,17 @@ EXPORT_SYMBOL_GPL(chip_wakeup); void host_wakeup_notify(struct wilc *wilc) { - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_2, 1); - release_bus(wilc, WILC_BUS_RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); } EXPORT_SYMBOL_GPL(host_wakeup_notify); void host_sleep_notify(struct wilc *wilc) { - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_1, 1); - release_bus(wilc, WILC_BUS_RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); } EXPORT_SYMBOL_GPL(host_sleep_notify); From patchwork Thu Jun 13 14:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804789 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4021F144D22; Thu, 13 Jun 2024 14:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; cv=none; b=FqsXDjTtnAY8LEmUf+UTh21eRgmsnypFE88cVSuyUltxh+gkG+RPL7dbmM4Eb/3+lYPzWPozw/PoT+9A4/f82p07n5/hyyUWZgH2NdFlREwMXTZvEcGf1H09uJMzQLmdmWAXpTts3F/TAFwAjmmp2skHOV5obM1kAb8twURLcUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; c=relaxed/simple; bh=4RT3k3qkDb51XkI7+op2d8Gu+d00tOAbnMzE7YADJbQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s69Fi1wU3leqIVyWlpsNo6Kd3fCwKfoKBY6D/Uu5NJwNv+Xrfu4eqFHabI7wfUrqR6bQVVt68iQ8TLF6D8E6TIJRBo7VoK6vUvn5QVj1Ie51ZYr9puKEapkAYUSth9X10TR4d2rnxMuJpffvst0elR1OztKQLNMwgoEqHEF/2vs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GsnwWXb1; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GsnwWXb1" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9F6721BF214; Thu, 13 Jun 2024 14:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KImdBPG69Vy3zZfpijKwF06u8+Zf/lYE5b5hwvY4Qas=; b=GsnwWXb1yinDepVUXtSQeF5RZvxsfwf1jbLv4K6tORU5gdAlgYLAZdxRJvR5cCBqETOjOH E/FSqctlHRnQojxlvydBbVlVjsOumCor4BzimB590DFoHW8JGP+96bXoQTKy/5T36HtYlp FWPClaaAmxL6FGkvtzyHQqbxBS5wFV29sMHUsCM7xlommbYoD87eLM2IGkDPD3KTzo013m tvCbcxsAsehqKJHnsoE4PxsgOUCRpBFc4GA4xjwuMitZI5GqdymVXru53Gp2S1OHu1GzyM 5UCq9ZXNUMdUJiCxigct30r10mZ3HkG+3W4Rdh7pZiv7aJ6pconNzYZ3Z+m1OA== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:42 +0200 Subject: [PATCH 3/6] wifi: wilc1000: do not keep sdio bus claimed during suspend/resume Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-3-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com There is no reason to keep the MMC host claimed during suspend. Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 4e478a2cd4cc..fb4de3de1140 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -269,7 +269,6 @@ static int wilc_sdio_suspend(struct device *dev) dev_err(&func->dev, "Fail reset sdio\n"); return ret; } - sdio_claim_host(func); return 0; } @@ -1000,7 +999,6 @@ static int wilc_sdio_resume(struct device *dev) struct wilc *wilc = sdio_get_drvdata(func); dev_info(dev, "sdio resume\n"); - sdio_release_host(func); wilc_sdio_init(wilc, true); if (wilc->suspend_event) From patchwork Thu Jun 13 14:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804120 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42725144D28; Thu, 13 Jun 2024 14:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; cv=none; b=IsrRFxS20GNZUbttzQVgwv0OlrImZvCO1ioTrqjR+qYDfDmhoodWe/SUTKEln+AN4k/KnRYMB0shmDw5xvra8zWpoc5BtJsZBH2TGdxftmO7lZiYsiKP2eQeg8o5ckDcmsOqBjOcyrguMSja9l14Xg5dt3XVINlIwTJb/FxFUIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; c=relaxed/simple; bh=/3/RjwKiLLAAqUv9PGd3NtY0FMHGe7Zhcncw6CpFJDY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Fvx6M/UshU1ORLMFP4br1orO3lBbEGeDsZzCJ3791/vHsFHPHlWmSCJiFT0hiEnOsgJnJko4hRwk636FjjmwlZf3nySfGyN4QD91H6WNfx6bsvO6m8lN4844YkvOYRxDD81zXSCjv4q/hITxZzbMuN4yipdc59CtjTvkY+6FAlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=obA6lYP1; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="obA6lYP1" Received: by mail.gandi.net (Postfix) with ESMTPSA id 094581BF20B; Thu, 13 Jun 2024 14:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EiSm/eUhJPdOIyUa5VFuIncGFB6F3tSxO/MVBLvrj6o=; b=obA6lYP1b5MFxeoJiVqPP5phg75NGILqBqn3OQSWn7qDIUS0GFj5JWpWoxJeMc+0JKVPmI 3ecr7Kcv+LbogiiGP4XXyjxBAPp3EjXYRVTxn1tFLR0mt8w3Ut9Bwonq4IITdVW2v91GEL 6+1n+ZWiqMjGbdCVT/+LvdXWJ1t7xk2HDFme3CnJ8uMOAC3zd5lvwB6BH4eD8LkX98fzUD 5pnHnK9lu7DbQaToC4ZqCWqQ38sH4lf3zt1I6tImB2PyFYJIJj5R9/F1u01BO35+wTCEgO aHnSSEIZiXX4XJ0C2fZWoT9iOPoIC78oZM+5WjFxZNuW/gP3VVpX+MkwaWvjtg== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:43 +0200 Subject: [PATCH 4/6] wifi: wilc1000: move sdio suspend method next to resume and pm ops definition Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-4-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com Just move the suspend method next to the resume method in the sdio part Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 47 +++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index fb4de3de1140..21398a3c600b 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -249,30 +249,6 @@ static bool wilc_sdio_is_init(struct wilc *wilc) return sdio_priv->isinit; } -static int wilc_sdio_suspend(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - struct wilc *wilc = sdio_get_drvdata(func); - int ret; - - dev_info(dev, "sdio suspend\n"); - - if (!IS_ERR(wilc->rtc_clk)) - clk_disable_unprepare(wilc->rtc_clk); - - if (wilc->suspend_event) { - host_sleep_notify(wilc); - } - - ret = wilc_sdio_reset(wilc); - if (ret) { - dev_err(&func->dev, "Fail reset sdio\n"); - return ret; - } - - return 0; -} - static int wilc_sdio_enable_interrupt(struct wilc *dev) { struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); @@ -993,6 +969,29 @@ static const struct wilc_hif_func wilc_hif_sdio = { .hif_is_init = wilc_sdio_is_init, }; +static int wilc_sdio_suspend(struct device *dev) +{ + struct sdio_func *func = dev_to_sdio_func(dev); + struct wilc *wilc = sdio_get_drvdata(func); + int ret; + + dev_info(dev, "sdio suspend\n"); + + if (!IS_ERR(wilc->rtc_clk)) + clk_disable_unprepare(wilc->rtc_clk); + + if (wilc->suspend_event) + host_sleep_notify(wilc); + + ret = wilc_sdio_reset(wilc); + if (ret) { + dev_err(&func->dev, "Fail reset sdio\n"); + return ret; + } + + return 0; +} + static int wilc_sdio_resume(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); From patchwork Thu Jun 13 14:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804119 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 401E1144D21; Thu, 13 Jun 2024 14:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; cv=none; b=GHm3lIiN+HZ4XXjaEQiHz1X8YIfP1QJfC7D3z3PX91SGP2mjmatjYNK0V3Za2czlZmvzvlilvwp5ka39IKkcbA+dGVDlU7/BMCWulJJxGyYvVBuFhgVq/hYo8KrLsW776Jz78cWspuAhHaIYgh7DXJHS4qTllXT0J5RxWUgIL0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287822; c=relaxed/simple; bh=GpFmutC7qNS5D63XKNVZU++STRMERLCcpZP+B831mbs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=abJ/ZOjurIjrspJgkBjYw3OtZzu7Afz4ZVH34Kgmbk1rzVgTuRhbX3hkaNkz6dcS0XHqXbp+LBSGbeMJUlrUVBVs96B6hKHP73/a1m9UvEvWYw5IpgH94cb0/o22Y+Eka6JFoQA0nOlgAwEdbxqvz0ZmQ3lKXu2J3+zxvZKYlrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=TXvnPkH9; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="TXvnPkH9" Received: by mail.gandi.net (Postfix) with ESMTPSA id 697C61BF212; Thu, 13 Jun 2024 14:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RClnKQFv64FuSlC1HxBHws576hIZFiDk+emFZ0rBLhM=; b=TXvnPkH95jxbM/0Oh9ooTTmgWKqly+qkpsIe4F8gyGh1TkJMU7P+cIP4hvbi7hBaTudAr2 QV4dF3kmbt+bzXGoqQDGMoFjukC49S83olv85zb9wE1B5kX3M+ZQo6mOXw7Pi3nKfNtrDw PEMDi8SMu1rUsVXOGQ4fTlXHQcgnApyhrWnIykBr+qV6WwB+q94i2tkIHzHDJ0J3KDaM7v olvbg+mZRK3rk66BXKyuGtyjBDg+qtsSHllStXNvTT/t+sLeJcJBSFBdaj9ckWcWEN+0N/ 0Xt+q6Fj49WpMWYVbXob72Dg3CSFa4ffNh6K3Y6RpCY3dnSStDOtCZ8CitgmKw== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:44 +0200 Subject: [PATCH 5/6] wifi: wilc1000: remove suspend/resume from cfg80211 part Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-5-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com WILC1000 suspend/resume implementation is currently composed of two parts: suspend/resume ops implemented in cfg80211 ops, which merely sets a flag, and suspend/resume ops in sdio/spi driver which, based on this flag, execute or not the suspend/resume mechanism. This dual set of ops is not really needed , so keep only the sdio part to implement suspend/resume. While doing so, remove the now unused suspend_event flag. Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 19 ------------------- drivers/net/wireless/microchip/wilc1000/netdev.h | 1 - drivers/net/wireless/microchip/wilc1000/sdio.c | 6 ++---- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index ba02e6cfd3ae..eb37b228d54e 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1617,23 +1617,6 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) return 0; } -static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) -{ - struct wilc *wl = wiphy_priv(wiphy); - - if (!wow && wilc_wlan_get_num_conn_ifcs(wl)) - wl->suspend_event = true; - else - wl->suspend_event = false; - - return 0; -} - -static int wilc_resume(struct wiphy *wiphy) -{ - return 0; -} - static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) { struct wilc *wl = wiphy_priv(wiphy); @@ -1739,8 +1722,6 @@ static const struct cfg80211_ops wilc_cfg80211_ops = { .set_power_mgmt = set_power_mgmt, .set_cqm_rssi_config = set_cqm_rssi_config, - .suspend = wilc_suspend, - .resume = wilc_resume, .set_wakeup = wilc_set_wakeup, .set_tx_power = set_tx_power, .get_tx_power = get_tx_power, diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index e59d1b6f5d7d..95bc8b8fe65a 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -272,7 +272,6 @@ struct wilc { const struct firmware *firmware; struct device *dev; - bool suspend_event; struct workqueue_struct *hif_workqueue; struct wilc_cfg cfg; diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 21398a3c600b..4e7014670945 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -980,8 +980,7 @@ static int wilc_sdio_suspend(struct device *dev) if (!IS_ERR(wilc->rtc_clk)) clk_disable_unprepare(wilc->rtc_clk); - if (wilc->suspend_event) - host_sleep_notify(wilc); + host_sleep_notify(wilc); ret = wilc_sdio_reset(wilc); if (ret) { @@ -1000,8 +999,7 @@ static int wilc_sdio_resume(struct device *dev) dev_info(dev, "sdio resume\n"); wilc_sdio_init(wilc, true); - if (wilc->suspend_event) - host_wakeup_notify(wilc); + host_wakeup_notify(wilc); return 0; } From patchwork Thu Jun 13 14:06:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 804787 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36B5F144D0B; Thu, 13 Jun 2024 14:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287823; cv=none; b=gM58BlYwNupmwO822rpPTA+9AqJsEt0JUrqFDdkXG80MzP374wHQFUZ/gSuGCH44H1QeYKXWYNk9rGqInIka3/1nKvX81hJjhU2KrGlTr4qkzI5juLgTFvHAW+wXkFUTQhTf/jclrRTSRD1oHcTV7DgQkCt2Olr/PcBB2vgwmb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718287823; c=relaxed/simple; bh=efT8/7km08T7pBrO07ujSxmypsAf8sMdycVHcxqyE5Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eehYYU25sVoWgnZySgxuHID9JReQaRC8cLn7fcwC6+C2sidYaJxS2eRys8jjDzj/v7W8dMhPfHRqFAiZj90pW25stVvMyeeyBTODmg9a6rxQLN3eyzBDvNJw+qks5VRltp0IyD978KOKbLwgRDX9tWLBoUbegHhwrackRrduaSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=j/sw2DNo; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j/sw2DNo" Received: by mail.gandi.net (Postfix) with ESMTPSA id C669B1BF217; Thu, 13 Jun 2024 14:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718287814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kjx+jpjANBXkWfNXv0n4w9Dw5J7tAkEhzVptEspIDqs=; b=j/sw2DNo4scE93+h+/6YT6j5G8ntNQmY3MY1vSjbswlG5tTcqpWWpcaTXq1zEw/Ri4e+r4 Y/14xT/tqSpncGGuvTdGeuDAbSuGq6OKh+i2yUXd1X/Rxm5k90RzP+31Xkko/KcvFc9T1j c1DsUqCsObAaooXmSJyWmWNXEZSMWICn7LBqGUwRUohunwbSNgKK41PZPWBt88QTwchlxN 1Kz27eYuCP3Ap3cJP3lGy2X7zcRGRMtI54GiFNOHJQ4fQ7SZe2APBxlR/I+43fNLTtiwW9 V31Z0aqHI2XLtDh1ijQrUK1tkdwiwuK3efmRS7x5B/4MWBJTAcsDeBKfO4duqA== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Thu, 13 Jun 2024 16:06:45 +0200 Subject: [PATCH 6/6] wifi: wilc1000: disable SDIO func IRQ before suspend Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240613-wilc_suspend-v1-6-c2f766d0988c@bootlin.com> References: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> In-Reply-To: <20240613-wilc_suspend-v1-0-c2f766d0988c@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , Thomas Petazzoni , linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com Issuing a system suspend command raises the following warning: WARNING: CPU: 0 PID: 15 at drivers/mmc/core/sdio.c:1042 mmc_sdio_suspend+0xd4/0x19c CPU: 0 PID: 15 Comm: kworker/u2:1 Not tainted 6.7.0-rc1-wt+ #710 Hardware name: Atmel SAMA5 Workqueue: events_unbound async_run_entry_fn unwind_backtrace from show_stack+0x18/0x1c show_stack from dump_stack_lvl+0x34/0x48 dump_stack_lvl from __warn+0x98/0x160 __warn from warn_slowpath_fmt+0xcc/0x140 warn_slowpath_fmt from mmc_sdio_suspend+0xd4/0x19c mmc_sdio_suspend from mmc_bus_suspend+0x50/0x70 mmc_bus_suspend from dpm_run_callback+0xe4/0x248 dpm_run_callback from __device_suspend+0x234/0x91c __device_suspend from async_suspend+0x24/0x9c async_suspend from async_run_entry_fn+0x6c/0x210 async_run_entry_fn from process_one_work+0x3a0/0x870 [...] This warning is due to a check in SDIO core ensuring that interrupts do not remain enabled for cards being powered down during suspend. WILC driver currently does not set the MMC_PM_KEEP_POWER flag, so disable interrupt when entering resume. Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 4e7014670945..0043f7a0fdf9 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -982,6 +982,8 @@ static int wilc_sdio_suspend(struct device *dev) host_sleep_notify(wilc); + wilc_sdio_disable_interrupt(wilc); + ret = wilc_sdio_reset(wilc); if (ret) { dev_err(&func->dev, "Fail reset sdio\n"); @@ -998,6 +1000,7 @@ static int wilc_sdio_resume(struct device *dev) dev_info(dev, "sdio resume\n"); wilc_sdio_init(wilc, true); + wilc_sdio_enable_interrupt(wilc); host_wakeup_notify(wilc);