Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: core: Set the Command Priority (CP) flag for RT requests

Make the UFS device execute realtime (RT) requests before other requests.
This will be used in Android to reduce the I/O latency of the foreground
app.

Note: UFS devices do not support CDL so using CDL is not a viable
alternative.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230921192335.676924-5-bvanassche@acm.org
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
00d2fa28 c788cf8a

+6 -1
+4
drivers/ufs/core/ufshcd.c
··· 2717 2717 */ 2718 2718 static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) 2719 2719 { 2720 + struct request *rq = scsi_cmd_to_rq(lrbp->cmd); 2721 + unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); 2720 2722 u8 upiu_flags; 2721 2723 2722 2724 if (hba->ufs_version <= ufshci_version(1, 1)) ··· 2728 2726 2729 2727 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, 2730 2728 lrbp->cmd->sc_data_direction, 0); 2729 + if (ioprio_class == IOPRIO_CLASS_RT) 2730 + upiu_flags |= UPIU_CMD_FLAGS_CP; 2731 2731 ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); 2732 2732 } 2733 2733
+2 -1
include/ufs/ufs.h
··· 98 98 UPIU_TRANSACTION_REJECT_UPIU = 0x3F, 99 99 }; 100 100 101 - /* UPIU Read/Write flags */ 101 + /* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS standard. */ 102 102 enum { 103 103 UPIU_CMD_FLAGS_NONE = 0x00, 104 + UPIU_CMD_FLAGS_CP = 0x04, 104 105 UPIU_CMD_FLAGS_WRITE = 0x20, 105 106 UPIU_CMD_FLAGS_READ = 0x40, 106 107 };