Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ed97506

Browse files
Asutosh Dasmartinkpetersen
authored andcommitted
scsi: ufs: core: mcq: Add completion support in poll
Complete CQE requests in poll. Assumption is that several poll completion may happen in different CPUs for the same completion queue. Hence a spin lock protection is added. Co-developed-by: Can Guo <[email protected]> Signed-off-by: Can Guo <[email protected]> Signed-off-by: Asutosh Das <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f87b2c4 commit ed97506

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba,
294294
return completed_reqs;
295295
}
296296

297+
unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
298+
struct ufs_hw_queue *hwq)
299+
{
300+
unsigned long completed_reqs;
301+
302+
spin_lock(&hwq->cq_lock);
303+
completed_reqs = ufshcd_mcq_poll_cqe_nolock(hba, hwq);
304+
spin_unlock(&hwq->cq_lock);
305+
306+
return completed_reqs;
307+
}
308+
297309
void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
298310
{
299311
struct ufs_hw_queue *hwq;
@@ -390,6 +402,7 @@ int ufshcd_mcq_init(struct ufs_hba *hba)
390402
hwq = &hba->uhq[i];
391403
hwq->max_entries = hba->nutrs;
392404
spin_lock_init(&hwq->sq_lock);
405+
spin_lock_init(&hwq->cq_lock);
393406
}
394407

395408
/* The very first HW queue serves device commands */

drivers/ufs/core/ufshcd-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba,
7575
struct ufs_hw_queue *hwq);
7676
struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
7777
struct request *req);
78+
unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
79+
struct ufs_hw_queue *hwq);
7880

7981
#define UFSHCD_MCQ_IO_QUEUE_OFFSET 1
8082
#define SD_ASCII_STD true

drivers/ufs/core/ufshcd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,6 +5461,13 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)
54615461
struct ufs_hba *hba = shost_priv(shost);
54625462
unsigned long completed_reqs, flags;
54635463
u32 tr_doorbell;
5464+
struct ufs_hw_queue *hwq;
5465+
5466+
if (is_mcq_enabled(hba)) {
5467+
hwq = &hba->uhq[queue_num + UFSHCD_MCQ_IO_QUEUE_OFFSET];
5468+
5469+
return ufshcd_mcq_poll_cqe_lock(hba, hwq);
5470+
}
54645471

54655472
spin_lock_irqsave(&hba->outstanding_lock, flags);
54665473
tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);

include/ufs/ufshcd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ struct ufs_hba {
10861086
* @sq_lock: serialize submission queue access
10871087
* @cq_tail_slot: current slot to which CQ tail pointer is pointing
10881088
* @cq_head_slot: current slot to which CQ head pointer is pointing
1089+
* @cq_lock: Synchronize between multiple polling instances
10891090
*/
10901091
struct ufs_hw_queue {
10911092
void __iomem *mcq_sq_head;
@@ -1103,6 +1104,7 @@ struct ufs_hw_queue {
11031104
spinlock_t sq_lock;
11041105
u32 cq_tail_slot;
11051106
u32 cq_head_slot;
1107+
spinlock_t cq_lock;
11061108
};
11071109

11081110
static inline bool is_mcq_enabled(struct ufs_hba *hba)

0 commit comments

Comments
 (0)