scsi: ufs: core: Change the monitor function argument types
Pass a SCSI command pointer instead of a struct ufshcd_lrb pointer. This patch prepares for combining the SCSI command and ufshcd_lrb data structures into a single data structure. Reviewed-by: Avri Altman <avri.altman@sandisk.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20251031204029.2883185-15-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
ae7bf255b1
commit
f59568f4e2
@@ -2295,19 +2295,20 @@ static inline int ufshcd_monitor_opcode2dir(u8 opcode)
|
|||||||
|
|
||||||
/* Must only be called for SCSI commands. */
|
/* Must only be called for SCSI commands. */
|
||||||
static inline bool ufshcd_should_inform_monitor(struct ufs_hba *hba,
|
static inline bool ufshcd_should_inform_monitor(struct ufs_hba *hba,
|
||||||
struct ufshcd_lrb *lrbp)
|
struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
const struct ufs_hba_monitor *m = &hba->monitor;
|
const struct ufs_hba_monitor *m = &hba->monitor;
|
||||||
|
struct request *rq = scsi_cmd_to_rq(cmd);
|
||||||
|
struct ufshcd_lrb *lrbp = &hba->lrb[rq->tag];
|
||||||
|
|
||||||
return (m->enabled &&
|
return m->enabled &&
|
||||||
(!m->chunk_size || m->chunk_size == lrbp->cmd->sdb.length) &&
|
(!m->chunk_size || m->chunk_size == cmd->sdb.length) &&
|
||||||
ktime_before(hba->monitor.enabled_ts, lrbp->issue_time_stamp));
|
ktime_before(hba->monitor.enabled_ts, lrbp->issue_time_stamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ufshcd_start_monitor(struct ufs_hba *hba,
|
static void ufshcd_start_monitor(struct ufs_hba *hba, struct scsi_cmnd *cmd)
|
||||||
const struct ufshcd_lrb *lrbp)
|
|
||||||
{
|
{
|
||||||
int dir = ufshcd_monitor_opcode2dir(*lrbp->cmd->cmnd);
|
int dir = ufshcd_monitor_opcode2dir(cmd->cmnd[0]);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(hba->host->host_lock, flags);
|
spin_lock_irqsave(hba->host->host_lock, flags);
|
||||||
@@ -2316,14 +2317,15 @@ static void ufshcd_start_monitor(struct ufs_hba *hba,
|
|||||||
spin_unlock_irqrestore(hba->host->host_lock, flags);
|
spin_unlock_irqrestore(hba->host->host_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ufshcd_update_monitor(struct ufs_hba *hba, const struct ufshcd_lrb *lrbp)
|
static void ufshcd_update_monitor(struct ufs_hba *hba, struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
int dir = ufshcd_monitor_opcode2dir(*lrbp->cmd->cmnd);
|
struct request *req = scsi_cmd_to_rq(cmd);
|
||||||
|
struct ufshcd_lrb *lrbp = &hba->lrb[req->tag];
|
||||||
|
int dir = ufshcd_monitor_opcode2dir(cmd->cmnd[0]);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(hba->host->host_lock, flags);
|
spin_lock_irqsave(hba->host->host_lock, flags);
|
||||||
if (dir >= 0 && hba->monitor.nr_queued[dir] > 0) {
|
if (dir >= 0 && hba->monitor.nr_queued[dir] > 0) {
|
||||||
const struct request *req = scsi_cmd_to_rq(lrbp->cmd);
|
|
||||||
struct ufs_hba_monitor *m = &hba->monitor;
|
struct ufs_hba_monitor *m = &hba->monitor;
|
||||||
ktime_t now, inc, lat;
|
ktime_t now, inc, lat;
|
||||||
|
|
||||||
@@ -2358,6 +2360,7 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
|
|||||||
struct ufshcd_lrb *lrbp,
|
struct ufshcd_lrb *lrbp,
|
||||||
struct ufs_hw_queue *hwq)
|
struct ufs_hw_queue *hwq)
|
||||||
{
|
{
|
||||||
|
struct scsi_cmnd *cmd = lrbp->cmd;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (hba->monitor.enabled) {
|
if (hba->monitor.enabled) {
|
||||||
@@ -2366,11 +2369,11 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
|
|||||||
lrbp->compl_time_stamp = ktime_set(0, 0);
|
lrbp->compl_time_stamp = ktime_set(0, 0);
|
||||||
lrbp->compl_time_stamp_local_clock = 0;
|
lrbp->compl_time_stamp_local_clock = 0;
|
||||||
}
|
}
|
||||||
if (lrbp->cmd) {
|
if (cmd) {
|
||||||
ufshcd_add_command_trace(hba, lrbp->cmd, UFS_CMD_SEND);
|
ufshcd_add_command_trace(hba, cmd, UFS_CMD_SEND);
|
||||||
ufshcd_clk_scaling_start_busy(hba);
|
ufshcd_clk_scaling_start_busy(hba);
|
||||||
if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
|
if (unlikely(ufshcd_should_inform_monitor(hba, cmd)))
|
||||||
ufshcd_start_monitor(hba, lrbp);
|
ufshcd_start_monitor(hba, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hba->mcq_enabled) {
|
if (hba->mcq_enabled) {
|
||||||
@@ -2386,8 +2389,7 @@ static inline void ufshcd_send_command(struct ufs_hba *hba,
|
|||||||
} else {
|
} else {
|
||||||
spin_lock_irqsave(&hba->outstanding_lock, flags);
|
spin_lock_irqsave(&hba->outstanding_lock, flags);
|
||||||
if (hba->vops && hba->vops->setup_xfer_req)
|
if (hba->vops && hba->vops->setup_xfer_req)
|
||||||
hba->vops->setup_xfer_req(hba, lrbp->task_tag,
|
hba->vops->setup_xfer_req(hba, lrbp->task_tag, !!cmd);
|
||||||
!!lrbp->cmd);
|
|
||||||
__set_bit(lrbp->task_tag, &hba->outstanding_reqs);
|
__set_bit(lrbp->task_tag, &hba->outstanding_reqs);
|
||||||
ufshcd_writel(hba, 1 << lrbp->task_tag,
|
ufshcd_writel(hba, 1 << lrbp->task_tag,
|
||||||
REG_UTP_TRANSFER_REQ_DOOR_BELL);
|
REG_UTP_TRANSFER_REQ_DOOR_BELL);
|
||||||
@@ -5628,19 +5630,17 @@ void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
|
|||||||
void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
|
void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
|
||||||
struct cq_entry *cqe)
|
struct cq_entry *cqe)
|
||||||
{
|
{
|
||||||
struct ufshcd_lrb *lrbp;
|
struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
|
||||||
struct scsi_cmnd *cmd;
|
struct scsi_cmnd *cmd = lrbp->cmd;
|
||||||
enum utp_ocs ocs;
|
enum utp_ocs ocs;
|
||||||
|
|
||||||
lrbp = &hba->lrb[task_tag];
|
|
||||||
if (hba->monitor.enabled) {
|
if (hba->monitor.enabled) {
|
||||||
lrbp->compl_time_stamp = ktime_get();
|
lrbp->compl_time_stamp = ktime_get();
|
||||||
lrbp->compl_time_stamp_local_clock = local_clock();
|
lrbp->compl_time_stamp_local_clock = local_clock();
|
||||||
}
|
}
|
||||||
cmd = lrbp->cmd;
|
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
|
if (unlikely(ufshcd_should_inform_monitor(hba, cmd)))
|
||||||
ufshcd_update_monitor(hba, lrbp);
|
ufshcd_update_monitor(hba, cmd);
|
||||||
ufshcd_add_command_trace(hba, cmd, UFS_CMD_COMP);
|
ufshcd_add_command_trace(hba, cmd, UFS_CMD_COMP);
|
||||||
cmd->result = ufshcd_transfer_rsp_status(hba, lrbp, cqe);
|
cmd->result = ufshcd_transfer_rsp_status(hba, lrbp, cqe);
|
||||||
ufshcd_release_scsi_cmd(hba, lrbp);
|
ufshcd_release_scsi_cmd(hba, lrbp);
|
||||||
|
|||||||
Reference in New Issue
Block a user