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

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Fix the polling implementation

Fix the following issues in ufshcd_poll():

- If polling succeeds, return a positive value.

- Do not complete polling requests from interrupt context because the
block layer expects these requests to be completed from thread
context. From block/bio.c:

If REQ_ALLOC_CACHE is set, the final put of the bio MUST be done from
process context, not hard/soft IRQ.

Fixes: eaab9b573054 ("scsi: ufs: Implement polling support")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20221118233717.441298-1-bvanassche@acm.org
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
ee8c88ca 4d450cf2

+26 -2
+26 -2
drivers/ufs/core/ufshcd.c
··· 5344 5344 } 5345 5345 } 5346 5346 5347 + /* Any value that is not an existing queue number is fine for this constant. */ 5348 + enum { 5349 + UFSHCD_POLL_FROM_INTERRUPT_CONTEXT = -1 5350 + }; 5351 + 5352 + static void ufshcd_clear_polled(struct ufs_hba *hba, 5353 + unsigned long *completed_reqs) 5354 + { 5355 + int tag; 5356 + 5357 + for_each_set_bit(tag, completed_reqs, hba->nutrs) { 5358 + struct scsi_cmnd *cmd = hba->lrb[tag].cmd; 5359 + 5360 + if (!cmd) 5361 + continue; 5362 + if (scsi_cmd_to_rq(cmd)->cmd_flags & REQ_POLLED) 5363 + __clear_bit(tag, completed_reqs); 5364 + } 5365 + } 5366 + 5347 5367 /* 5348 5368 * Returns > 0 if one or more commands have been completed or 0 if no 5349 5369 * requests have been completed. ··· 5380 5360 WARN_ONCE(completed_reqs & ~hba->outstanding_reqs, 5381 5361 "completed: %#lx; outstanding: %#lx\n", completed_reqs, 5382 5362 hba->outstanding_reqs); 5363 + if (queue_num == UFSHCD_POLL_FROM_INTERRUPT_CONTEXT) { 5364 + /* Do not complete polled requests from interrupt context. */ 5365 + ufshcd_clear_polled(hba, &completed_reqs); 5366 + } 5383 5367 hba->outstanding_reqs &= ~completed_reqs; 5384 5368 spin_unlock_irqrestore(&hba->outstanding_lock, flags); 5385 5369 5386 5370 if (completed_reqs) 5387 5371 __ufshcd_transfer_req_compl(hba, completed_reqs); 5388 5372 5389 - return completed_reqs; 5373 + return completed_reqs != 0; 5390 5374 } 5391 5375 5392 5376 /** ··· 5421 5397 * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we 5422 5398 * do not want polling to trigger spurious interrupt complaints. 5423 5399 */ 5424 - ufshcd_poll(hba->host, 0); 5400 + ufshcd_poll(hba->host, UFSHCD_POLL_FROM_INTERRUPT_CONTEXT); 5425 5401 5426 5402 return IRQ_HANDLED; 5427 5403 }