mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Levin, Alexander (Sasha Levin)" <alexander.levin@one.verizon.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "subhashj@codeaurora.org" <subhashj@codeaurora.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"Levin,
	Alexander (Sasha Levin)" <alexander.levin@one.verizon.com>
Subject: [PATCH AUTOSEL for-4.9 18/53] scsi: ufs: add capability to keep auto bkops always enabled
Date: Wed, 8 Nov 2017 20:49:59 +0000	[thread overview]
Message-ID: <20171108204940.27321-18-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171108204940.27321-1-alexander.levin@verizon.com>

From: "subhashj@codeaurora.org" <subhashj@codeaurora.org>

[ Upstream commit 4e768e7645ec4ffa92ee163643777b261ae97142 ]

UFS device requires to perform bkops (back ground operations) periodically
but host can control (via auto-bkops parameter of device) when device can
perform bkops based on its performance requirements. In general, host
would like to enable the device's auto-bkops only when it's not doing any
regular data transfer but sometimes device may not behave properly if host
keeps the auto-bkops disabled. This change adds the capability to let the
device auto-bkops always enabled except suspend.

Reviewed-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 drivers/scsi/ufs/ufshcd.c | 33 ++++++++++++++++++++++-----------
 drivers/scsi/ufs/ufshcd.h | 13 +++++++++++++
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index edb06e466224..530034bc2d13 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3781,18 +3781,25 @@ out:
 }
 
 /**
- * ufshcd_force_reset_auto_bkops - force enable of auto bkops
+ * ufshcd_force_reset_auto_bkops - force reset auto bkops state
  * @hba: per adapter instance
  *
  * After a device reset the device may toggle the BKOPS_EN flag
  * to default value. The s/w tracking variables should be updated
- * as well. Do this by forcing enable of auto bkops.
+ * as well. This function would change the auto-bkops state based on
+ * UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND.
  */
-static void  ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
+static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
 {
-	hba->auto_bkops_enabled = false;
-	hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
-	ufshcd_enable_auto_bkops(hba);
+	if (ufshcd_keep_autobkops_enabled_except_suspend(hba)) {
+		hba->auto_bkops_enabled = false;
+		hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
+		ufshcd_enable_auto_bkops(hba);
+	} else {
+		hba->auto_bkops_enabled = true;
+		hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS;
+		ufshcd_disable_auto_bkops(hba);
+	}
 }
 
 static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status)
@@ -6138,11 +6145,15 @@ static int ufshcd_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 			goto set_old_link_state;
 	}
 
-	/*
-	 * If BKOPs operations are urgently needed at this moment then
-	 * keep auto-bkops enabled or else disable it.
-	 */
-	ufshcd_urgent_bkops(hba);
+	if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
+		ufshcd_enable_auto_bkops(hba);
+	else
+		/*
+		 * If BKOPs operations are urgently needed at this moment then
+		 * keep auto-bkops enabled or else disable it.
+		 */
+		ufshcd_urgent_bkops(hba);
+
 	hba->clk_gating.is_suspended = false;
 
 	if (ufshcd_is_clkscaling_enabled(hba))
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 04509827fe64..f2170d5058a8 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -548,6 +548,14 @@ struct ufs_hba {
 	 * CAUTION: Enabling this might reduce overall UFS throughput.
 	 */
 #define UFSHCD_CAP_INTR_AGGR (1 << 4)
+	/*
+	 * This capability allows the device auto-bkops to be always enabled
+	 * except during suspend (both runtime and suspend).
+	 * Enabling this capability means that device will always be allowed
+	 * to do background operation when it's active but it might degrade
+	 * the performance of ongoing read/write operations.
+	 */
+#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
 
 	struct devfreq *devfreq;
 	struct ufs_clk_scaling clk_scaling;
@@ -645,6 +653,11 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)
 	BUG_ON(!hba);
 	return hba->priv;
 }
+static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
+							struct ufs_hba *hba)
+{
+	return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
+}
 
 extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
 extern int ufshcd_runtime_resume(struct ufs_hba *hba);
-- 
2.11.0

  parent reply	other threads:[~2017-11-08 21:00 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 20:49 [PATCH AUTOSEL for-4.9 01/53] extcon: Remove potential problem when calling extcon_register_notifier() Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 04/53] spi: imx: adjust watermark level according to transfer length Levin, Alexander (Sasha Levin)
2017-11-08 20:57   ` Mark Brown
2017-11-08 21:39     ` Levin, Alexander (Sasha Levin)
2017-11-08 22:11       ` Mark Brown
2017-11-08 22:48         ` Levin, Alexander (Sasha Levin)
2017-11-08 23:11           ` Mark Brown
2017-11-09  0:00             ` Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 05/53] ARM: dts: Fix compatible for ti81xx uarts for 8250 Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 02/53] extcon: palmas: Check the parent instance to prevent the NULL Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 03/53] fm10k: request reset when mbx->state changes Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 07/53] ARM: OMAP2+: Fix init for multiple quirks for the same SoC Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 09/53] ARM: dts: omap5-uevm: Allow bootloader to configure USB Ethernet MAC Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 08/53] ARM: dts: Fix omap3 off mode pull defines Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 06/53] ARM: dts: Fix am335x and dm814x scm syscon to probe children Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 12/53] ata: SATA_MV should depend on HAS_DMA Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 11/53] ata: SATA_HIGHBANK " Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 10/53] ata: ATA_BMDMA " Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 17/53] scsi: ufs-qcom: Fix module autoload Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 14/53] igb: reset the PHY before reading the PHY ID Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 13/53] drm/sti: sti_vtg: Handle return NULL error from devm_ioremap_nocache Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 15/53] igb: close/suspend race in netif_device_detach Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 16/53] igb: Fix hw_dbg logging in igb_update_flash_i210 Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 19/53] tcp: provide timestamps for partial writes Levin, Alexander (Sasha Levin)
2017-11-08 20:49 ` Levin, Alexander (Sasha Levin) [this message]
2017-11-08 20:49 ` [PATCH AUTOSEL for-4.9 20/53] staging: rtl8188eu: fix incorrect ERROR tags from logs Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 21/53] x86/irq, trace: Add __irq_entry annotation to x86's platform IRQ handlers Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 22/53] scsi: lpfc: Add missing memory barrier Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 23/53] scsi: lpfc: FCoE VPort enable-disable does not bring up the VPort Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 24/53] scsi: lpfc: Correct host name in symbolic_name field Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 25/53] scsi: lpfc: Correct issue leading to oops during link reset Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 28/53] power: supply: axp288_fuel_gauge: Read 15 bit values 2 registers at a time Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 26/53] scsi: lpfc: Clear the VendorVersion in the PLOGI/PLOGI ACC payload Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 27/53] rtc: rx8010: change lock mechanism Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 30/53] ALSA: vx: Don't try to update capture stream before running Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 31/53] ALSA: vx: Fix possible transfer overflow Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 29/53] power: supply: axp288_fuel_gauge: Read 12 bit values 2 registers at a time Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 32/53] drm/omap: panel-sony-acx565akm.c: Add MODULE_ALIAS Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 34/53] backlight: adp5520: Fix error handling in adp5520_bl_probe() Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 35/53] gpu: drm: mgag200: mgag200_main:- Handle error from pci_iomap Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 33/53] backlight: lcd: Fix race condition during register Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 36/53] ALSA: hda/realtek - Add new codec ID ALC299 Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 38/53] ixgbe: Configure advertised speeds correctly for KR/KX backplane Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 37/53] arm64: dts: NS2: reserve memory for Nitro firmware Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 39/53] ixgbe: fix AER error handling Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 40/53] ixgbe: handle close/suspend race with netif_device_detach/present Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 41/53] ixgbe: Fix reporting of 100Mb capability Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 44/53] ixgbe: do not disable FEC from the driver Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 42/53] ixgbe: Reduce I2C retry count on X550 devices Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 43/53] ixgbe: add mask for 64 RSS queues Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 46/53] staging: wilc1000: Fix endian sparse warning Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 48/53] MIPS: End asm function prologue macros with .insn Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 47/53] staging: greybus: add host device function pointer checks Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 45/53] staging: rtl8712: fixed little endian problem Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 49/53] MIPS: init: Ensure bootmem does not corrupt reserved memory Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 50/53] MIPS: init: Ensure reserved memory regions are not added to bootmem Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 53/53] MIPS: Use Makefile.postlink to insert relocations into vmlinux Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 51/53] MIPS: traps: Ensure L1 & L2 ECC checking match for CM3 systems Levin, Alexander (Sasha Levin)
2017-11-08 20:50 ` [PATCH AUTOSEL for-4.9 52/53] MIPS: Netlogic: Exclude netlogic,xlp-pic code from XLR builds Levin, Alexander (Sasha Levin)

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=20171108204940.27321-18-alexander.levin@verizon.com \
    --to=alexander.levin@one.verizon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=subhashj@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®