Skip to content

Add support for periodic BKOPS

Maya Erez linux-arm-msm linux-mmc lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 1 replyIn review
  2. v42 patches 4 repliesSuperseded

Changes in v5 from the cover letter

- Do not allow BKOPS operation in all levels to be blocking
- Change the periodic check for BKOPS need to be based on percentage of changed sector
- Add BKOPS statistics

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mmc: core: Add support for idle time BKOPSDocumentation/mmc/mmc-dev-attrs.txt drivers/mmc/card/block.c drivers/mmc/card/queue.c +4 more+291 -370 replies
2/3mmc: allow the host controller to poll for BKOPS completiondrivers/mmc/core/core.c drivers/mmc/core/mmc.c include/linux/mmc/card.h +2 more+91 -20 replies
3/3mmc: core: Add MMC BKOPS statistics and debugfs ability to print themdrivers/mmc/core/bus.c drivers/mmc/core/core.c drivers/mmc/core/debugfs.c +2 more+183 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/3] Add support for periodic BKOPS

Devices have various maintenance operations need to perform internally. In order to reduce latencies during time critical operations like read and write, it is better to execute maintenance operations in other times - when the host is not being serviced. Such operations are called Background operations (BKOPS).
The device notifies the status of the BKOPS need by updating BKOPS_STATUS (EXT_CSD byte [246]).

According to the standard a host that supports BKOPS shall check the status periodically and start background operations as needed, so that the device has enough time for its maintenance operations.

This patch adds support for this periodic check of the BKOPS status. Since foreground operations are of higher priority than background operations the host will check the need for BKOPS when it is idle, and in case of an incoming request the BKOPS operation will be interrupted.

When the mmcqd thread is idle, a delayed work is created to check the need for BKOPS. The time to start the delayed work can be set by the host controller. If this time is not set, a default time is used. If the card raised an exception with need for urgent BKOPS (level 2/3) a flag will be set to indicate MMC to start the BKOPS activity when it becomes idle.

Since running the BKOPS too often can impact the eMMC endurance, the card need for BKOPS is not checked every time MMC is idle (despite of cases of exception raised). In order to estimate when is the best time to check for BKOPS need the host will take into account the card capacity and percentages of changed sectors in the card. A future enhancement can be to check the card need for BKOPS only in case of random activity.

This patch is based on the periodic BKOPS implementation in version 8 of "support BKOPS feature for eMMC" patch. The patch was modified to answer the following issues:
- Since mmc_start_bkops is called from two contexts now, mmc_claim_host was moved to the beginning of the function
- Also, the check of doing_bkops should be protected when determing if an HPI is needed due to the same reason.

Changes in v5:
- Do not allow BKOPS operation in all levels to be blocking
- Change the periodic check for BKOPS need to be based on percentage of changed sector
- Add BKOPS statistics

Changes in v4:
- Separate the polling for BKOPS completion to a different patch
- add a flag to indicate if polling for card completion is required

Changes in v3:
- Move the call to stop_bkops to block.c.
This allows us to remove the mmc_claim_host from inside the function and doesn't cause additional degradation due to un-neccessary calim host operation

Changes in v2:
- Check the number of written / discarded sectors as the trigger for checking the BKOPS need.
- Code review fixes

Maya Erez (3):
mmc: core: Add support for idle time BKOPS
mmc: allow the host controller to poll for BKOPS completion
mmc: core: Add MMC BKOPS statistics and debugfs ability to print them

 Documentation/mmc/mmc-dev-attrs.txt |    9 +
 drivers/mmc/card/block.c            |   96 ++++++++++++-
 drivers/mmc/card/queue.c            |    2 +
 drivers/mmc/core/bus.c              |    2 +
 drivers/mmc/core/core.c             |  286 +++++++++++++++++++++++++++++++----
 drivers/mmc/core/debugfs.c          |  114 ++++++++++++++
 drivers/mmc/core/mmc.c              |   20 +++
 include/linux/mmc/card.h            |   64 ++++++++-
 include/linux/mmc/core.h            |    5 +
 include/linux/mmc/host.h            |    2 +-
 10 files changed, 563 insertions(+), 37 deletions(-)
Signature · 4 lines
1.7.3.3
-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation