Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v4 00/29] Optimize the hot path in the UFS driver
@ 2025-09-12 18:21 Bart Van Assche
  2025-09-12 18:21 ` [PATCH v4 01/29] scsi: core: Support allocating reserved commands Bart Van Assche
                   ` (28 more replies)
  0 siblings, 29 replies; 52+ messages in thread
From: Bart Van Assche @ 2025-09-12 18:21 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche

Hi Martin,

This patch series optimizes the hot path of the UFS driver by making
struct scsi_cmnd and struct ufshcd_lrb adjacent. Making these two data
structures adjacent is realized as follows:

@@ -9040,6 +9046,7 @@ static const struct scsi_host_template ufshcd_driver_template = {
     .name            = UFSHCD,
     .proc_name        = UFSHCD,
     .map_queues        = ufshcd_map_queues,
+    .cmd_size        = sizeof(struct ufshcd_lrb),
     .init_cmd_priv        = ufshcd_init_cmd_priv,
     .queuecommand        = ufshcd_queuecommand,
     .mq_poll        = ufshcd_poll,

The following changes had to be made prior to making these two data
structures adjacent:
* Add support for driver-internal and reserved commands in the SCSI core.
* Instead of making the reserved command slot (hba->reserved_slot)
  invisible to the SCSI core, let the SCSI core allocate a reserved command.
* Remove all UFS data structure members that are no longer needed
  because struct scsi_cmnd and struct ufshcd_lrb are now adjacent
* Call ufshcd_init_lrb() from inside ufshcd_queuecommand() instead of
  calling this function before I/O starts. This is necessary because
  ufshcd_memory_alloc() allocates fewer instances than the block layer
  allocates requests. See also the following code in the block layer
  core:

    if (blk_mq_init_request(set, hctx->fq->flush_rq, hctx_idx,
                hctx->numa_node))

  Although the UFS driver could be modified such that ufshcd_init_lrb()
  is called from ufshcd_init_cmd_priv(), realizing this would require
  moving the memory allocations that happen from inside
  ufshcd_memory_alloc() into ufshcd_init_cmd_priv(). That would make
  this patch series even larger. Although ufshcd_init_lrb() is called for each
  command, the benefits of reduced indirection and better cache efficiency
  outweigh the small overhead of per-command lrb initialization.
* ufshcd_add_scsi_host() happens now before any device management
  commands are submitted. This change is necessary because this patch
  makes device management command allocation happen when the SCSI host
  is allocated.
* Allocate as many command slots as the host controller supports. Decrease
  host->cmds_per_lun if necessary once it is clear whether or not the UFS
  device supports less command slots than the host controller.

Changes compared to v3:
 - Fixed a spelling error in patch 1 and left out a superfluous if-statement.
 - Left out scsi_host_template.alloc_pseudo_sdev and allocate a pseudo SCSI
   device if either nr_reserved_cmds > 0 or .queue_reserved_commands has been
   set.
 - Left out the 'pseudo_sdev' local variable from scsi_forget_host().
 - Removed a backwards jump from scsi_get_pseudo_dev().
 - Included a bug fix for synchronous scanning.
 - Skip scsi_track_queue_full() and scsi_handle_queue_ramp_up() for pseudo SCSI
   devices.
 - Extended the scsi_execute_rq() functionality.
 - Use scsi_execute_rq() for submitting reserved commands instead of
   blk_execute_rq().
 - Dropped the patch that introduces scsi_get_internal_cmd() and
   scsi_put_internal_cmd().

Changes compared to v2:
 - Removed scsi_host_update_can_queue() and also the UFS driver refactoring
   patches that were introduced to support this call.
 - Added .queue_reserved_command(). Added ufshcd_queue_reserved_command().
 - Removed a BUG_ON() statement from ufshcd_get_dev_mgmt_cmd().
 - Modified and renamed ufshcd_mcq_decide_queue_depth().

Changes compared to v1:
 - Left out the kernel patches related to support for const SCSI command
   arguments.
 - Added SCSI core patches for allocating a pseudo SCSI device and reserved
   command support.
 - Added several kernel patches to switch the UFS driver from a hardcoded
   reserved slot to calling scsi_get_internal_cmd().
 - Enable .alloc_pseudo_sdev in the scsi_debug driver.

Bart Van Assche (26):
  scsi: core: Move two statements
  scsi: core: Make the budget map optional
  scsi: core: Extend the scsi_execute_cmd() functionality
  scsi_debug: Allocate a pseudo SCSI device
  ufs: core: Move an assignment in ufshcd_mcq_process_cqe()
  ufs: core: Change the type of one ufshcd_add_cmd_upiu_trace() argument
  ufs: core: Only call ufshcd_add_command_trace() for SCSI commands
  ufs: core: Change the type of one ufshcd_add_command_trace() argument
  ufs: core: Change the type of one ufshcd_send_command() argument
  ufs: core: Only call ufshcd_should_inform_monitor() for SCSI commands
  ufs: core: Change the monitor function argument types
  ufs: core: Rework ufshcd_mcq_compl_pending_transfer()
  ufs: core: Rework ufshcd_eh_device_reset_handler()
  ufs: core: Rework the SCSI host queue depth calculation code
  ufs: core: Allocate the SCSI host earlier
  ufs: core: Call ufshcd_init_lrb() later
  ufs: core: Use hba->reserved_slot
  ufs: core: Make the reserved slot a reserved request
  ufs: core: Do not clear driver-private command data
  ufs: core: Optimize the hot path
  ufs: core: Pass a SCSI pointer instead of an LRB pointer
  ufs: core: Remove the ufshcd_lrb task_tag member
  ufs: core: Make blk_mq_tagset_busy_iter() skip reserved requests
  ufs: core: Move code out of ufshcd_wait_for_dev_cmd()
  ufs: core: Rework the ufshcd_issue_dev_cmd() callers
  ufs: core: Switch to scsi_execute_cmd()

Hannes Reinecke (2):
  scsi: core: Support allocating reserved commands
  scsi: core: Support allocating a pseudo SCSI device

John Garry (1):
  scsi: core: Introduce .queue_reserved_command()

 drivers/scsi/hosts.c             |   15 +
 drivers/scsi/scsi.c              |   11 +-
 drivers/scsi/scsi_debug.c        |   14 +
 drivers/scsi/scsi_error.c        |    3 +
 drivers/scsi/scsi_lib.c          |   99 ++-
 drivers/scsi/scsi_priv.h         |    2 +
 drivers/scsi/scsi_scan.c         |   76 ++-
 drivers/scsi/scsi_sysfs.c        |    5 +-
 drivers/ufs/core/ufs-mcq.c       |   51 +-
 drivers/ufs/core/ufshcd-crypto.h |   18 +-
 drivers/ufs/core/ufshcd-priv.h   |   20 +-
 drivers/ufs/core/ufshcd.c        | 1045 +++++++++++++++++-------------
 include/scsi/scsi_cmnd.h         |    2 +
 include/scsi/scsi_device.h       |   53 +-
 include/scsi/scsi_host.h         |   33 +-
 include/ufs/ufshcd.h             |   12 -
 16 files changed, 902 insertions(+), 557 deletions(-)


^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2025-09-19  7:45 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 18:21 [PATCH v4 00/29] Optimize the hot path in the UFS driver Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 01/29] scsi: core: Support allocating reserved commands Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 02/29] scsi: core: Move two statements Bart Van Assche
2025-09-16  8:03   ` John Garry
2025-09-16  8:28   ` Hannes Reinecke
2025-09-12 18:21 ` [PATCH v4 03/29] scsi: core: Make the budget map optional Bart Van Assche
2025-09-16  8:34   ` Hannes Reinecke
2025-09-16 15:45     ` Bart Van Assche
2025-09-16 20:38     ` Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 04/29] scsi: core: Support allocating a pseudo SCSI device Bart Van Assche
2025-09-16  8:21   ` John Garry
2025-09-16  8:44     ` Hannes Reinecke
2025-09-16  9:21       ` John Garry
2025-09-12 18:21 ` [PATCH v4 05/29] scsi: core: Introduce .queue_reserved_command() Bart Van Assche
2025-09-16  9:33   ` John Garry
2025-09-12 18:21 ` [PATCH v4 06/29] scsi: core: Extend the scsi_execute_cmd() functionality Bart Van Assche
2025-09-12 20:03   ` michael.christie
2025-09-12 20:14     ` Bart Van Assche
2025-09-16  9:09   ` John Garry
2025-09-16 15:44     ` Bart Van Assche
2025-09-17 13:08       ` John Garry
2025-09-17 18:21         ` Bart Van Assche
2025-09-17 23:42           ` Bart Van Assche
2025-09-18  8:01             ` John Garry
2025-09-18 19:49               ` Bart Van Assche
2025-09-19  7:45                 ` John Garry
2025-09-12 18:21 ` [PATCH v4 07/29] scsi_debug: Allocate a pseudo SCSI device Bart Van Assche
2025-09-17 12:09   ` John Garry
2025-09-17 21:37     ` Bart Van Assche
2025-09-18  7:30       ` John Garry
2025-09-12 18:21 ` [PATCH v4 08/29] ufs: core: Move an assignment in ufshcd_mcq_process_cqe() Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 09/29] ufs: core: Change the type of one ufshcd_add_cmd_upiu_trace() argument Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 10/29] ufs: core: Only call ufshcd_add_command_trace() for SCSI commands Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 11/29] ufs: core: Change the type of one ufshcd_add_command_trace() argument Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 12/29] ufs: core: Change the type of one ufshcd_send_command() argument Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 13/29] ufs: core: Only call ufshcd_should_inform_monitor() for SCSI commands Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 14/29] ufs: core: Change the monitor function argument types Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 15/29] ufs: core: Rework ufshcd_mcq_compl_pending_transfer() Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 16/29] ufs: core: Rework ufshcd_eh_device_reset_handler() Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 17/29] ufs: core: Rework the SCSI host queue depth calculation code Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 18/29] ufs: core: Allocate the SCSI host earlier Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 19/29] ufs: core: Call ufshcd_init_lrb() later Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 20/29] ufs: core: Use hba->reserved_slot Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 21/29] ufs: core: Make the reserved slot a reserved request Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 22/29] ufs: core: Do not clear driver-private command data Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 23/29] ufs: core: Optimize the hot path Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 24/29] ufs: core: Pass a SCSI pointer instead of an LRB pointer Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 25/29] ufs: core: Remove the ufshcd_lrb task_tag member Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 26/29] ufs: core: Make blk_mq_tagset_busy_iter() skip reserved requests Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 27/29] ufs: core: Move code out of ufshcd_wait_for_dev_cmd() Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 28/29] ufs: core: Rework the ufshcd_issue_dev_cmd() callers Bart Van Assche
2025-09-12 18:21 ` [PATCH v4 29/29] ufs: core: Switch to scsi_execute_cmd() Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox