Received: by 10.223.176.5 with SMTP id f5csp3838013wra; Mon, 29 Jan 2018 20:55:36 -0800 (PST) X-Google-Smtp-Source: AH8x225f2HLdLRjbwKm+E3E6zySpSo4PyGCVD+3WrhmbiKvS8a/L2Scu2wVfXLm6yoB2S6yHgLID X-Received: by 10.98.253.5 with SMTP id p5mr29217200pfh.132.1517288136632; Mon, 29 Jan 2018 20:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517288136; cv=none; d=google.com; s=arc-20160816; b=d7VXF5niD3iS6nu/qA0VfnjPLf0UKDjmdnVzi6RNP3AOK/Mt6Tsv1DkoMJKJ2Hx2J1 OLrVtu97xmvt5O6IfJb2LF1GaQGcOC31yz1RsSVtCxBFdk9o1EiyHkn8Q5Z5uHnElxsN XxlPYW9SKBrOGUZ/dqo4fp6QOyYG9EzNr889+/G+gTDY2lz/ycajAA2KeAmI29lNzUpz pivNGnWwLVhLvyASB8kjbTJpUO+A2ZcAFKLswfANfAKmWGeHcC2XP58PSrFF8/A0EsFn Qtcdy8PYkG1WDAX302f8GM5f9cDbOcNCw6yTZBqKWkIN1rJKyv6j+oqjEwhmcJBu8PIE TYGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=t3FfHwoQ4R4yD0SbfYMBS7wzWx67yo4Tr2/2uEl2n3U=; b=fC66j3EuWMibFAxLgH46VKkwfqAfaorTv7j4Of5xYhDQQzSkuqncUN3b2jMekOrGdR wiJzKs6/Cvf073MDVjHxS61T61FUR/kxZMOeUX4ukA2CmbqC2j3cdrs9cLb9PQuIEX40 hkStofGGBXKeGjf5sTCzG1E4tAId3vFS4ixbO7rCWc5xyoR4zF/p2tlbGpvNzXfoD5ie b9BVhZC9dAedgamZr8DOSS3O1YPOe9/RkrbgQbvX8XVLC5IQZy4Lfp2hlfijyLUq2Gtg 056UEN5HODzdRaflFmaFQB1WWM12Zd71+Vu2Lv+XGfiq3nDW0LBu3j1LPQTyUH8+bnua Ocgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i90si1169727pfd.147.2018.01.29.20.55.20; Mon, 29 Jan 2018 20:55:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525AbeA3Ey4 (ORCPT + 99 others); Mon, 29 Jan 2018 23:54:56 -0500 Received: from sabertooth01.qualcomm.com ([65.197.215.72]:10389 "EHLO sabertooth01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752232AbeA3Eyz (ORCPT ); Mon, 29 Jan 2018 23:54:55 -0500 X-IronPort-AV: E=Sophos;i="5.46,433,1511856000"; d="scan'208";a="123125336" Received: from unknown (HELO ironmsg03-tai.qualcomm.com) ([10.249.140.8]) by sabertooth01.qualcomm.com with ESMTP; 29 Jan 2018 20:54:54 -0800 X-IronPort-AV: E=McAfee;i="5900,7806,8789"; a="277583" X-MGA-submission: =?us-ascii?q?MDHN36voq5YcN9RlbVs3vGTZdxrFI1MdNsx+qY?= =?us-ascii?q?MCOfmmbwONVTJ3Aykgos8FladgNZ/p15FzaDX83VM1FdBQEawFYnEKue?= =?us-ascii?q?toGOBVdN4KMd5C+CczNreu5FvBmjGRP4VTuCjZY6o2FdEFXo6XYBNx1F?= =?us-ascii?q?ZZ?= Received: from asutoshd-linux.qualcomm.com ([10.206.24.163]) by ironmsg03-tai.qualcomm.com with ESMTP; 29 Jan 2018 20:54:33 -0800 Received: by asutoshd-linux.qualcomm.com (Postfix, from userid 92687) id A16C71AE1; Tue, 30 Jan 2018 10:24:31 +0530 (IST) From: Asutosh Das To: subhashj@codeaurora.org, cang@codeaurora.org, vivek.gautam@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Venkat Gopalakrishnan , Asutosh Das , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/1] scsi: ufs: make sure all interrupts are processed Date: Tue, 30 Jan 2018 10:24:26 +0530 Message-Id: <1517288066-13171-1-git-send-email-asutoshd@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Venkat Gopalakrishnan As multiple requests are submitted to the ufs host controller in parallel there could be instances where the command completion interrupt arrives later for a request that is already processed earlier as the corresponding doorbell was cleared when handling the previous interrupt. Read the interrupt status in a loop after processing the received interrupt to catch such interrupts and handle it. Signed-off-by: Venkat Gopalakrishnan Signed-off-by: Asutosh Das --- drivers/scsi/ufs/ufshcd.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 8af2af3..58d81de 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5357,19 +5357,30 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba) u32 intr_status, enabled_intr_status; irqreturn_t retval = IRQ_NONE; struct ufs_hba *hba = __hba; + int retries = hba->nutrs; spin_lock(hba->host->host_lock); intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS); - enabled_intr_status = - intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE); - if (intr_status) - ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS); + /* + * There could be max of hba->nutrs reqs in flight and in worst case + * if the reqs get finished 1 by 1 after the interrupt status is + * read, make sure we handle them by checking the interrupt status + * again in a loop until we process all of the reqs before returning. + */ + do { + enabled_intr_status = + intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE); + if (intr_status) + ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS); + if (enabled_intr_status) { + ufshcd_sl_intr(hba, enabled_intr_status); + retval = IRQ_HANDLED; + } + + intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS); + } while (intr_status && --retries); - if (enabled_intr_status) { - ufshcd_sl_intr(hba, enabled_intr_status); - retval = IRQ_HANDLED; - } spin_unlock(hba->host->host_lock); return retval; } -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.