Skip to content

Commit 00d2fa2

Browse files
bvanasschemartinkpetersen
authored andcommitted
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>
1 parent c788cf8 commit 00d2fa2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,6 +2717,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
27172717
*/
27182718
static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
27192719
{
2720+
struct request *rq = scsi_cmd_to_rq(lrbp->cmd);
2721+
unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
27202722
u8 upiu_flags;
27212723

27222724
if (hba->ufs_version <= ufshci_version(1, 1))
@@ -2726,6 +2728,8 @@ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
27262728

27272729
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
27282730
lrbp->cmd->sc_data_direction, 0);
2731+
if (ioprio_class == IOPRIO_CLASS_RT)
2732+
upiu_flags |= UPIU_CMD_FLAGS_CP;
27292733
ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
27302734
}
27312735

include/ufs/ufs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ enum upiu_response_transaction {
9898
UPIU_TRANSACTION_REJECT_UPIU = 0x3F,
9999
};
100100

101-
/* UPIU Read/Write flags */
101+
/* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS standard. */
102102
enum {
103103
UPIU_CMD_FLAGS_NONE = 0x00,
104+
UPIU_CMD_FLAGS_CP = 0x04,
104105
UPIU_CMD_FLAGS_WRITE = 0x20,
105106
UPIU_CMD_FLAGS_READ = 0x40,
106107
};

0 commit comments

Comments
 (0)