Received: by 10.192.165.148 with SMTP id m20csp1710389imm; Thu, 3 May 2018 04:16:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5brvp9rE1uD5GX1GPQJFyc5rls0s0A0zegbi264Zg7iY2AOpCCi0vkahmTM5OYRfGsqOr X-Received: by 2002:a63:7058:: with SMTP id a24-v6mr19432286pgn.101.1525346197815; Thu, 03 May 2018 04:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525346197; cv=none; d=google.com; s=arc-20160816; b=DUkkbV7+79t9q7txsWtTPDrVgPIu1VSTip1+M2a4ePDcFFonzgZGVQRVtA8n9iSKH1 bgABhq3KsqiwcDgTbIopIfaJvdV8zJNQ9FArN4dksGaVz6WGdRO8RQYxlkuLNOIwyVtl VIHUC+7W4l/42Of//xze0MCi1ZhPSqociy301b//AIMu9Mc0Re6/oMvj5Y3EDmqU9Hp1 6m5ubyL+4wP6LjHSsvho9Cn8nnn1hz7djnN+vZoP/xaoAV9If1pvJjExyW2LBKIusvEu 0yMPbCB0R+93S6Bal3Rywo6SRUH7qW21gqa7gy784kabqfnjDSfZ+r4DOTfEVTJPceeJ owNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=T7DNTFoqdMtoLKfjkJbzJXt91dSPe+F/7HFgefD1tDY=; b=LSYeEZzqZlelvXDGOYoNKugIZ+RiHz3xJyPeMGflWPb4vAN0fSXhwk0DwY0yQW1HKd bsYIKPRDDfygIFlO4dO3fQzwahgqo7+hUvcegW/KKkWU+X0/dKU9m97TUiK8+VelOVYI 6/qD6+cTFLxPO58AlyhWO68Ebm0vzxUKvIaxUIU4HWXFo0e/AFEm4u10WhjzRel8NKuR oILNuQRmR9U9HUW2gGvr1Txm0KFCJhha1GRQSQSZBta25nVOIeSizjTaFjno4R0ocsZd /kpkgCxASxy6T41H4dADKp/KAtudToujvtzAhI7q/etNqZII5c2KVlPBaLyIEmJgEVG4 zExg== 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 b184-v6si11081801pgc.25.2018.05.03.04.16.23; Thu, 03 May 2018 04:16:37 -0700 (PDT) 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 S1751704AbeECLOa (ORCPT + 99 others); Thu, 3 May 2018 07:14:30 -0400 Received: from alexa-out-tai-01.qualcomm.com ([103.229.16.226]:12836 "EHLO alexa-out-tai-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbeECLOV (ORCPT ); Thu, 3 May 2018 07:14:21 -0400 X-IronPort-AV: E=Sophos;i="5.49,358,1520870400"; d="scan'208";a="443711" Received: from ironmsg02-tai.qualcomm.com ([10.249.140.7]) by alexa-out-tai-01.qualcomm.com with ESMTP; 03 May 2018 19:07:54 +0800 X-IronPort-AV: E=McAfee;i="5900,7806,8881"; a="7390448" Received: from asutoshd-linux.qualcomm.com ([10.206.24.163]) by ironmsg02-tai.qualcomm.com with ESMTP; 03 May 2018 19:07:41 +0800 Received: by asutoshd-linux.qualcomm.com (Postfix, from userid 92687) id CAA282E8F; Thu, 3 May 2018 16:37:38 +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, asutoshd@codeaurora.org, linux-mmc@vger.kernel.org Cc: linux-scsi@vger.kernel.org, Venkat Gopalakrishnan , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 08/10] scsi: ufs: make sure all interrupts are processed Date: Thu, 3 May 2018 16:37:20 +0530 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: 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 c35a076..09b7a3f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5383,19 +5383,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.