* [PATCH AUTOSEL 5.10 09/34] scsi: ufs: Simplify ufshcd_clear_cmd()
[not found] <20220628022241.595835-1-sashal@kernel.org>
@ 2022-06-28 2:22 ` Sasha Levin
2022-06-28 2:22 ` [PATCH AUTOSEL 5.10 10/34] scsi: ufs: Support clearing multiple commands at once Sasha Levin
1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2022-06-28 2:22 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bart Van Assche, Stanley Chu, Adrian Hunter, Martin K . Petersen,
Sasha Levin, jejb, matthias.bgg, beanhuo, avri.altman,
daejun7.park, linux-scsi, linux-arm-kernel, linux-mediatek
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit da8badd7d3583f447eac2ab65a332f2d773deca1 ]
Remove the local variable 'err'. This patch does not change any
functionality.
Link: https://lore.kernel.org/r/20220613214442.212466-2-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ea6ceab1a1b2..1b32d4f4e21e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2649,7 +2649,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
static int
ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
{
- int err = 0;
unsigned long flags;
u32 mask = 1 << tag;
@@ -2662,11 +2661,8 @@ ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
* wait for for h/w to clear corresponding bit in door-bell.
* max. wait is 1 sec.
*/
- err = ufshcd_wait_for_register(hba,
- REG_UTP_TRANSFER_REQ_DOOR_BELL,
- mask, ~mask, 1000, 1000);
-
- return err;
+ return ufshcd_wait_for_register(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL,
+ mask, ~mask, 1000, 1000);
}
static int
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 5.10 10/34] scsi: ufs: Support clearing multiple commands at once
[not found] <20220628022241.595835-1-sashal@kernel.org>
2022-06-28 2:22 ` [PATCH AUTOSEL 5.10 09/34] scsi: ufs: Simplify ufshcd_clear_cmd() Sasha Levin
@ 2022-06-28 2:22 ` Sasha Levin
2022-06-29 12:59 ` Pavel Machek
1 sibling, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2022-06-28 2:22 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Bart Van Assche, Stanley Chu, Adrian Hunter, Martin K . Petersen,
Sasha Levin, jejb, matthias.bgg, beanhuo, avri.altman,
daejun7.park, linux-scsi, linux-arm-kernel, linux-mediatek
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit d1a7644648b7cdacaf8d1013a4285001911e9bc8 ]
Modify ufshcd_clear_cmd() such that it supports clearing multiple commands
at once instead of one command at a time. This change will be used in a
later patch to reduce the time spent in the reset handler.
Link: https://lore.kernel.org/r/20220613214442.212466-3-bvanassche@acm.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ufs/ufshcd.c | 42 ++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1b32d4f4e21e..9c6c7fa90a7f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -679,17 +679,28 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
}
/**
- * ufshcd_utrl_clear - Clear a bit in UTRLCLR register
+ * ufshcd_utrl_clear() - Clear requests from the controller request list.
* @hba: per adapter instance
- * @pos: position of the bit to be cleared
+ * @mask: mask with one bit set for each request to be cleared
*/
-static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
+static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 mask)
{
if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
- ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
- else
- ufshcd_writel(hba, ~(1 << pos),
- REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+ mask = ~mask;
+ /*
+ * From the UFSHCI specification: "UTP Transfer Request List CLear
+ * Register (UTRLCLR): This field is bit significant. Each bit
+ * corresponds to a slot in the UTP Transfer Request List, where bit 0
+ * corresponds to request slot 0. A bit in this field is set to ‘0’
+ * by host software to indicate to the host controller that a transfer
+ * request slot is cleared. The host controller
+ * shall free up any resources associated to the request slot
+ * immediately, and shall set the associated bit in UTRLDBR to ‘0’. The
+ * host software indicates no change to request slots by setting the
+ * associated bits in this field to ‘1’. Bits in this field shall only
+ * be set ‘1’ or ‘0’ by host software when UTRLRSR is set to ‘1’."
+ */
+ ufshcd_writel(hba, ~mask, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
}
/**
@@ -2646,15 +2657,18 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
return ufshcd_compose_devman_upiu(hba, lrbp);
}
-static int
-ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
+/*
+ * Clear all the requests from the controller for which a bit has been set in
+ * @mask and wait until the controller confirms that these requests have been
+ * cleared.
+ */
+static int ufshcd_clear_cmds(struct ufs_hba *hba, u32 mask)
{
unsigned long flags;
- u32 mask = 1 << tag;
/* clear outstanding transaction before retry */
spin_lock_irqsave(hba->host->host_lock, flags);
- ufshcd_utrl_clear(hba, tag);
+ ufshcd_utrl_clear(hba, mask);
spin_unlock_irqrestore(hba->host->host_lock, flags);
/*
@@ -2744,7 +2758,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
err = -ETIMEDOUT;
dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
__func__, lrbp->task_tag);
- if (!ufshcd_clear_cmd(hba, lrbp->task_tag))
+ if (!ufshcd_clear_cmds(hba, 1U << lrbp->task_tag))
/* successfully cleared the command, retry if needed */
err = -EAGAIN;
/*
@@ -6577,7 +6591,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
/* clear the commands that were pending for corresponding LUN */
for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
if (hba->lrb[pos].lun == lun) {
- err = ufshcd_clear_cmd(hba, pos);
+ err = ufshcd_clear_cmds(hba, 1U << pos);
if (err)
break;
}
@@ -6680,7 +6694,7 @@ static int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag)
goto out;
}
- err = ufshcd_clear_cmd(hba, tag);
+ err = ufshcd_clear_cmds(hba, 1U << tag);
if (err)
dev_err(hba->dev, "%s: Failed clearing cmd at tag %d, err %d\n",
__func__, tag, err);
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH AUTOSEL 5.10 10/34] scsi: ufs: Support clearing multiple commands at once
2022-06-28 2:22 ` [PATCH AUTOSEL 5.10 10/34] scsi: ufs: Support clearing multiple commands at once Sasha Levin
@ 2022-06-29 12:59 ` Pavel Machek
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2022-06-29 12:59 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Bart Van Assche, Stanley Chu,
Adrian Hunter, Martin K . Petersen, jejb, matthias.bgg, beanhuo,
avri.altman, daejun7.park, linux-scsi, linux-arm-kernel,
linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
Hi!
> [ Upstream commit d1a7644648b7cdacaf8d1013a4285001911e9bc8 ]
>
> Modify ufshcd_clear_cmd() such that it supports clearing multiple commands
> at once instead of one command at a time. This change will be used in a
> later patch to reduce the time spent in the reset handler.
This and "scsi: ufs: Simplify ufshcd_clear_cmd()" are not really
bugfixes. Patch they are preparing for is not queued for 5.10-stable.
Please drop.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-29 12:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220628022241.595835-1-sashal@kernel.org>
2022-06-28 2:22 ` [PATCH AUTOSEL 5.10 09/34] scsi: ufs: Simplify ufshcd_clear_cmd() Sasha Levin
2022-06-28 2:22 ` [PATCH AUTOSEL 5.10 10/34] scsi: ufs: Support clearing multiple commands at once Sasha Levin
2022-06-29 12:59 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).