[PATCH] scsi: ufs: read door bell register after clearing interrupt aggregation
In interrupt context, after reading and comparing the UTRLDBR to hba->outstanding_request and before resetting the interrupt aggregation, there might be completion of another transfer request (TR). Such TRs might get stuck, pending, until the next interrupt is generated. The fix reads the UTRLDBR after resetting the interrupt aggregation and handles completed TRs. Signed-off-by: Dolev Raviv diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4dca9b4..30c84d8 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1915,6 +1915,13 @@ static void ufshcd_uic_cmd_compl(struct ufs_hba *hba) /** * ufshcd_transfer_req_compl - handle SCSI and query command completion * @hba: per adapter instance + * + * Resetting interrupt aggregation counters first and reading the DOOR_BELL + * afterward , allows us to handle all the completed requests. + * In order to prevent other interrupts starvation the DB is read once + * after reset. The down side of this solution is the possibility of false + * interrupt if device completes another request after resetting aggregation + * and before reading the DB. */ static void ufshcd_transfer_req_compl(struct ufs_hba *hba) { @@ -1924,47 +1931,36 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba) u32 tr_doorbell; int result; int index; - bool int_aggr_reset = false; + + /* Reset interrupt aggregation counters */ + ufshcd_config_int_aggr(hba, INT_AGGR_RESET); tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); completed_reqs = tr_doorbell ^ hba->outstanding_reqs; - for (index = 0; index < hba->nutrs; index++) { - if (test_bit(index, &completed_reqs)) { - lrbp = &hba->lrb[index]; - cmd = lrbp->cmd; - /* -* Don't skip resetting interrupt aggregation counters -* if a regular command is present. -*/ - int_aggr_reset |= !lrbp->intr_cmd; - - if (cmd) { - result = ufshcd_transfer_rsp_status(hba, lrbp); - scsi_dma_unmap(cmd); - cmd->result = result; - /* Mark completed command as NULL in LRB */ - lrbp->cmd = NULL; - clear_bit_unlock(index, &hba->lrb_in_use); - /* Do not touch lrbp after scsi done */ - cmd->scsi_done(cmd); - } else if (lrbp->command_type == - UTP_CMD_TYPE_DEV_MANAGE) { - if (hba->dev_cmd.complete) - complete(hba->dev_cmd.complete); - } - } /* end of if */ - } /* end of for */ + for_each_set_bit(index, &completed_reqs, hba->nutrs) { + lrbp = &hba->lrb[index]; + cmd = lrbp->cmd; + if (cmd) { + result = ufshcd_transfer_rsp_status(hba, lrbp); + scsi_dma_unmap(cmd); + cmd->result = result; + /* Mark completed command as NULL in LRB */ + lrbp->cmd = NULL; + clear_bit_unlock(index, &hba->lrb_in_use); + /* Do not touch lrbp after scsi done */ + cmd->scsi_done(cmd); + } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) { + if (hba->dev_cmd.complete) + complete(hba->dev_cmd.complete); + } + } /* end of for_each_set_bit */ /* clear corresponding bits of completed commands */ hba->outstanding_reqs ^= completed_reqs; /* we might have free'd some tags above */ wake_up(&hba->dev_cmd.tag_wq); - - /* Reset interrupt aggregation counters */ - if (int_aggr_reset) - ufshcd_config_int_aggr(hba, INT_AGGR_RESET); } /** @@ -2569,6 +2565,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) int poll_cnt; u8 resp = 0xF; struct ufshcd_lrb *lrbp; + u32 reg; host = cmd->device->host; hba = shost_priv(host); @@ -2578,6 +2575,13 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) if (!(test_bit(tag, &hba->outstanding_reqs))) goto out; + reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); + if (!(reg & (1 << tag))) { + dev_err(hba->dev, + "%s: cmd was completed, but without a notifying intr, tag = %d", + __func__, tag); + } + lrbp = &hba->lrb[tag]; for (poll_cnt = 100; poll_cnt; poll_cnt--) { err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrb
Re: [PATCH v2 0/6] scsi: ufs: some fixes and updates
Hi Jeon, Can you specify your dependencies pleas. I was having trouble applying it above scsi/misc branch with the following patches: Sujit Reddy Thumma (4): scsi: ufs: Fix broken task management command implementation scsi: ufs: Fix hardware race conditions while aborting a command scsi: ufs: Fix device and host reset methods scsi: ufs: Improve UFS fatal error handling > This path series contain driver's fixes and updates. > > Changes in v2: > - [scsi: ufs: amend the ocs handling with fatal error] is excluded. >Host behavior needs to be defined clearly in UFSHCI specification. > - Some minor changes are applied with comments from Subhash, Sujit and > Santosh. > > Seungwon Jeon (6): > scsi: ufs: find out sense data over scsi status values > scsi: ufs: fix the setting interrupt aggregation counter > scsi: ufs: add dme configuration primitives > scsi: ufs: add unipro attribute IDs > scsi: ufs: add operation for the uic power mode change > scsi: ufs: configure the attribute for power mode > > drivers/scsi/ufs/ufs.h|1 + > drivers/scsi/ufs/ufshcd.c | 336 > ++--- > drivers/scsi/ufs/ufshcd.h | 54 +++ > drivers/scsi/ufs/ufshci.h | 22 +++- > drivers/scsi/ufs/unipro.h | 151 > 5 files changed, 513 insertions(+), 51 deletions(-) > > Thanks, > Seungwon Jeon > > -- > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 05/16] megaraid: clean up unnecessary MSI/MSI-X capability find
>> PCI_MSIX_FLAGS, >>control & >>~PCI_MSIX_FLAGS_ENABLE); >> } >> -- >> 1.7.1 >> >> > Acked-by: Sumit Saxena Hi James, Can you merge this patch? Thanks! Yijing. > > -- Thanks! Yijing -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/9] scsi: ufs: Add support for sending NOP OUT UPIU
On 8/23/2013 11:47 PM, James Bottomley wrote: On Tue, 2013-07-30 at 00:35 +0530, Santosh Y wrote: From: Sujit Reddy Thumma As part of device initialization sequence, sending NOP OUT UPIU and waiting for NOP IN UPIU response is mandatory. This confirms that the device UFS Transport (UTP) layer is functional and the host can configure the device with further commands. Add support for sending NOP OUT UPIU to check the device connection path and test whether the UTP layer on the device side is functional during initialization. A tag is acquired from the SCSI tag map space in order to send the device management command. When the tag is acquired by internal command the scsi command is rejected with host busy flag in order to requeue the request. To avoid frequent collisions between internal commands and scsi commands the device management command tag is allocated in the opposite direction w.r.t block layer tag allocation. Signed-off-by: Sujit Reddy Thumma Signed-off-by: Dolev Raviv Signed-off-by: Santosh Y This signoff chain looks wrong to me. The patch has quite a long history. Originally, it was sent in by Sujit, then later resent by Dolev with his signoff, then Sujit did a V2 which incorrectly seemed to include Dolev's signoff (that's not correct: signoffs should follow the chain of transmission, so a new patch wouldn't have a previous transmission signoff). Initially we had two patches - scsi: ufs: add support for query requests authored by Dolev and scsi: ufs: Add support for sending NOP OUT UPIU authored by me. Based on a possible design issue with the former patch, Dolev merged the patch into the later (NOP OUT patch). http://thread.gmane.org/gmane.linux.ports.arm.msm/4202/focus=1505731 Since some of the contents are picked from the original patch during rework, I have asked Dolev include his Signed-off-by as a co-author. Then we got a V3 which was tested by Maya Erez, and finally a v4 which looks to have no testers. In your last submission, you picked up this signoff, so I've changed it to a reviewed-by which seems to be the most appropriate (although I'm not entirely sure Dolev did review the v4 patch). If this is wrong and Dolev did rewrite the patch (so is one of the authors, which would explain the signoff chain) let me know and I'll edit it in the tree (rebasing is acceptable to get the correct history). James -- Regards, Sujit -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] arcmsr: Support Areca new SATA Raid Adapter ARC1214/1224/1264/1284
From: Ching Support Areca new SATA Raid adapter ARC1214/1224/1264/1284. Modify maximum outstanding command number, notify command complete with auto request sense Signed-off-by: Ching -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] arcmsr: Fix command throttling for ARC188x series
From: Ching Fix command throttling for ARC188x series adapter. Signed-off-by: Ching --- patch2 Description: Binary data
[PATCH 3/3] arcmsr: Fix bug of updating adapter firmware through ioctl(ARCHTTP) interface
From: Ching Fix bug of updating adapter firmware through ioctl(ARCHTTP) interface. Signed-off-by: Ching --- patch3 Description: Binary data