All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Daniel Mack <daniel@zonque.org>,
	Chris Ball <chris@printf.net>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Kalle Valo <kvalo@codeaurora.org>
Subject: [PATCH 4.14 13/89] libertas: fix suspend and resume for SDIO connected cards
Date: Fri,  7 Sep 2018 23:09:07 +0200	[thread overview]
Message-ID: <20180907210854.391338923@linuxfoundation.org> (raw)
In-Reply-To: <20180907210852.341064285@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Daniel Mack <daniel@zonque.org>

commit 7444a8092906ed44c09459780c56ba57043e39b1 upstream.

Prior to commit 573185cc7e64 ("mmc: core: Invoke sdio func driver's PM
callbacks from the sdio bus"), the MMC core used to call into the power
management functions of SDIO clients itself and removed the card if the
return code was non-zero. IOW, the mmc handled errors gracefully and didn't
upchain them to the pm core.

Since this change, the mmc core relies on generic power management
functions which treat all errors as a reason to cancel the suspend
immediately. This causes suspend attempts to fail when the libertas
driver is loaded.

To fix this, power down the card explicitly in if_sdio_suspend() when we
know we're about to lose power and return success. Also set a flag in these
cases, and power up the card again in if_sdio_resume().

Fixes: 573185cc7e64 ("mmc: core: Invoke sdio func driver's PM callbacks from the sdio bus")
Cc: <stable@vger.kernel.org>
Signed-off-by: Daniel Mack <daniel@zonque.org>
Reviewed-by: Chris Ball <chris@printf.net>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/wireless/marvell/libertas/dev.h     |    1 
 drivers/net/wireless/marvell/libertas/if_sdio.c |   30 +++++++++++++++++++-----
 2 files changed, 25 insertions(+), 6 deletions(-)

--- a/drivers/net/wireless/marvell/libertas/dev.h
+++ b/drivers/net/wireless/marvell/libertas/dev.h
@@ -104,6 +104,7 @@ struct lbs_private {
 	u8 fw_ready;
 	u8 surpriseremoved;
 	u8 setup_fw_on_resume;
+	u8 power_up_on_resume;
 	int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
 	void (*reset_card) (struct lbs_private *priv);
 	int (*power_save) (struct lbs_private *priv);
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -1290,15 +1290,23 @@ static void if_sdio_remove(struct sdio_f
 static int if_sdio_suspend(struct device *dev)
 {
 	struct sdio_func *func = dev_to_sdio_func(dev);
-	int ret;
 	struct if_sdio_card *card = sdio_get_drvdata(func);
+	struct lbs_private *priv = card->priv;
+	int ret;
 
 	mmc_pm_flag_t flags = sdio_get_host_pm_caps(func);
+	priv->power_up_on_resume = false;
 
 	/* If we're powered off anyway, just let the mmc layer remove the
 	 * card. */
-	if (!lbs_iface_active(card->priv))
-		return -ENOSYS;
+	if (!lbs_iface_active(priv)) {
+		if (priv->fw_ready) {
+			priv->power_up_on_resume = true;
+			if_sdio_power_off(card);
+		}
+
+		return 0;
+	}
 
 	dev_info(dev, "%s: suspend: PM flags = 0x%x\n",
 		 sdio_func_id(func), flags);
@@ -1306,9 +1314,14 @@ static int if_sdio_suspend(struct device
 	/* If we aren't being asked to wake on anything, we should bail out
 	 * and let the SD stack power down the card.
 	 */
-	if (card->priv->wol_criteria == EHS_REMOVE_WAKEUP) {
+	if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
 		dev_info(dev, "Suspend without wake params -- powering down card\n");
-		return -ENOSYS;
+		if (priv->fw_ready) {
+			priv->power_up_on_resume = true;
+			if_sdio_power_off(card);
+		}
+
+		return 0;
 	}
 
 	if (!(flags & MMC_PM_KEEP_POWER)) {
@@ -1321,7 +1334,7 @@ static int if_sdio_suspend(struct device
 	if (ret)
 		return ret;
 
-	ret = lbs_suspend(card->priv);
+	ret = lbs_suspend(priv);
 	if (ret)
 		return ret;
 
@@ -1336,6 +1349,11 @@ static int if_sdio_resume(struct device
 
 	dev_info(dev, "%s: resume: we're back\n", sdio_func_id(func));
 
+	if (card->priv->power_up_on_resume) {
+		if_sdio_power_on(card);
+		wait_event(card->pwron_waitq, card->priv->fw_ready);
+	}
+
 	ret = lbs_resume(card->priv);
 
 	return ret;



  parent reply	other threads:[~2018-09-07 21:25 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 21:08 [PATCH 4.14 00/89] 4.14.69-stable review Greg Kroah-Hartman
2018-09-07 21:08 ` [PATCH 4.14 01/89] net: 6lowpan: fix reserved space for single frames Greg Kroah-Hartman
2018-09-07 21:08 ` [PATCH 4.14 02/89] net: mac802154: tx: expand tailroom if necessary Greg Kroah-Hartman
2018-09-07 21:08 ` [PATCH 4.14 03/89] 9p/net: Fix zero-copy path in the 9p virtio transport Greg Kroah-Hartman
2018-09-07 21:08 ` [PATCH 4.14 04/89] spi: davinci: fix a NULL pointer dereference Greg Kroah-Hartman
2018-09-07 21:08 ` [PATCH 4.14 05/89] spi: pxa2xx: Add support for Intel Ice Lake Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 06/89] spi: spi-fsl-dspi: Fix imprecise abort on VF500 during probe Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 07/89] spi: cadence: Change usleep_range() to udelay(), for atomic context Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 08/89] mmc: renesas_sdhi_internal_dmac: fix #define RST_RESERVED_BITS Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 09/89] readahead: stricter check for bdi io_pages Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 10/89] block: blk_init_allocated_queue() set q->fq as NULL in the fail case Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 11/89] block: really disable runtime-pm for blk-mq Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 12/89] drm/i915/userptr: reject zero user_size Greg Kroah-Hartman
2018-09-07 21:09 ` Greg Kroah-Hartman [this message]
2018-09-07 21:09 ` [PATCH 4.14 14/89] media: Revert "[media] tvp5150: fix pad format frame height" Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 15/89] mailbox: xgene-slimpro: Fix potential NULL pointer dereference Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 16/89] Replace magic for trusting the secondary keyring with #define Greg Kroah-Hartman
2018-09-07 21:09   ` Greg Kroah-Hartman
2018-09-07 21:09   ` Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 17/89] Fix kexec forbidding kernels signed with keys in the secondary keyring to boot Greg Kroah-Hartman
2018-09-07 21:09   ` Greg Kroah-Hartman
2018-09-07 21:09   ` Greg Kroah-Hartman
2018-09-07 21:09   ` Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 18/89] powerpc/fadump: handle crash memory ranges array index overflow Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 19/89] powerpc/pseries: Fix endianness while restoring of r3 in MCE handler Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 20/89] powerpc/powernv/pci: Work around races in PCI bridge enabling Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 21/89] cxl: Fix wrong comparison in cxl_adapter_context_get() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 22/89] ib_srpt: Fix a use-after-free in srpt_close_ch() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 23/89] RDMA/rxe: Set wqe->status correctly if an unexpected response is received Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 24/89] 9p: fix multiple NULL-pointer-dereferences Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 25/89] fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 26/89] 9p/virtio: fix off-by-one error in sg list bounds check Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 27/89] net/9p/client.c: version pointer uninitialized Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 28/89] net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 29/89] dm integrity: change suspending variable from bool to int Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 30/89] dm thin: stop no_space_timeout worker when switching to write-mode Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 31/89] dm cache metadata: save in-core policy_hint_size to on-disk superblock Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 32/89] dm cache metadata: set dirty on all cache blocks after a crash Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 33/89] dm crypt: dont decrease device limits Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 35/89] Drivers: hv: vmbus: Reset the channel callback in vmbus_onoffer_rescind() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 36/89] iio: sca3000: Fix missing return in switch Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 37/89] iio: ad9523: Fix displayed phase Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 38/89] iio: ad9523: Fix return value for ad952x_store() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 39/89] extcon: Release locking when sending the notification of connector state Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 40/89] vmw_balloon: fix inflation of 64-bit GFNs Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 41/89] vmw_balloon: do not use 2MB without batching Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 42/89] vmw_balloon: VMCI_DOORBELL_SET does not check status Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 43/89] vmw_balloon: fix VMCI use when balloon built into kernel Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 44/89] rtc: omap: fix potential crash on power off Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 45/89] tracing: Do not call start/stop() functions when tracing_on does not change Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 46/89] tracing/blktrace: Fix to allow setting same value Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 47/89] printk/tracing: Do not trace printk_nmi_enter() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 48/89] livepatch: Validate module/old func name length Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 49/89] uprobes: Use synchronize_rcu() not synchronize_sched() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 50/89] mfd: hi655x: Fix regmap area declared size for hi655x Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 51/89] ovl: fix wrong use of impure dir cache in ovl_iterate() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 52/89] drivers/block/zram/zram_drv.c: fix bug storing backing_dev Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 53/89] cpufreq: governor: Avoid accessing invalid governor_data Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 54/89] PM / sleep: wakeup: Fix build error caused by missing SRCU support Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 55/89] KVM: VMX: fixes for vmentry_l1d_flush module parameter Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 56/89] KVM: PPC: Book3S: Fix guest DMA when guest partially backed by THP pages Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 57/89] xtensa: limit offsets in __loop_cache_{all,page} Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 58/89] xtensa: increase ranges in ___invalidate_{i,d}cache_all Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 59/89] block, bfq: return nbytes and not zero from struct cftype .write() method Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 60/89] pnfs/blocklayout: off by one in bl_map_stripe() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 61/89] NFSv4 client live hangs after live data migration recovery Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 62/89] NFSv4: Fix locking in pnfs_generic_recover_commit_reqs Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 63/89] NFSv4: Fix a sleep in atomic context in nfs4_callback_sequence() Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 64/89] ARM: tegra: Fix Tegra30 Cardhu PCA954x reset Greg Kroah-Hartman
2018-09-07 21:09 ` [PATCH 4.14 65/89] mm/tlb: Remove tlb_remove_table() non-concurrent condition Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 66/89] iommu/vt-d: Add definitions for PFSID Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 67/89] iommu/vt-d: Fix dev iotlb pfsid use Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 68/89] sys: dont hold uts_sem while accessing userspace memory Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 69/89] userns: move user access out of the mutex Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 70/89] ubifs: Fix memory leak in lprobs self-check Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 71/89] Revert "UBIFS: Fix potential integer overflow in allocation" Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 72/89] ubifs: Check data node size before truncate Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 73/89] ubifs: xattr: Dont operate on deleted inodes Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 74/89] ubifs: Fix synced_i_size calculation for xattr inodes Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 75/89] pwm: tiehrpwm: Dont use emulation mode bits to control PWM output Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 76/89] pwm: tiehrpwm: Fix disabling of output of PWMs Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 77/89] fb: fix lost console when the user unplugs a USB adapter Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 78/89] udlfb: set optimal write delay Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 79/89] getxattr: use correct xattr length Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 80/89] libnvdimm: fix ars_status output length calculation Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 81/89] bcache: release dc->writeback_lock properly in bch_writeback_thread() Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 82/89] cap_inode_getsecurity: use d_find_any_alias() instead of d_find_alias() Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 83/89] perf auxtrace: Fix queue resize Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 84/89] crypto: vmx - Fix sleep-in-atomic bugs Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 88/89] fs/quota: Fix spectre gadget in do_quotactl Greg Kroah-Hartman
2018-09-07 21:10 ` [PATCH 4.14 89/89] arm64: mm: always enable CONFIG_HOLES_IN_ZONE Greg Kroah-Hartman
2018-09-07 22:37 ` [PATCH 4.14 00/89] 4.14.69-stable review Nathan Chancellor
2018-09-08  8:28   ` Greg Kroah-Hartman
2018-09-08 21:16 ` Guenter Roeck
2018-09-09  8:43   ` Greg Kroah-Hartman
2018-09-09 15:56     ` Guenter Roeck
2018-09-09  4:26 ` Naresh Kamboju
2018-09-10 15:42 ` Shuah Khan

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=20180907210854.391338923@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=chris@printf.net \
    --cc=daniel@zonque.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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.