Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2513432imm; Wed, 16 May 2018 14:14:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZor1v0uaM3jTkgKWOElkOTDvJuzGmn3uYeaO/+XzR0l+V2d7xmxqNIw2MiVjpUZndSwxDm6 X-Received: by 2002:a17:902:8c81:: with SMTP id t1-v6mr2472681plo.310.1526505270355; Wed, 16 May 2018 14:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526505270; cv=none; d=google.com; s=arc-20160816; b=WK4khLZyExpytrzv11xIquZTsuu1aLmLNfwnsZFbUm2j5wh8UvMgKGLpiQBBnQ5P1b Q/kVi+3u1LJ31yNbf8ZPlNbqmjlsdQ8usudwkAfeKtS3oh2ekhzfad9naJ0FZM7FzeKq ZMQZIBcyLw1n/AL/ZxNBr5ZRsjFBvrRJdipBgSMXmvxFiiOL4AL2fVZB7nMQOJPZFPnE ccmyTYtQZiTkgxnyVSZDWIXB8XW2JKKbXTVegTEVJTVUNR/yAOlKfBC2Qyw3wNIM658x /WQvYrz4d+w0eWoeA7ETEgkdwYylsWb0moPVBn+YZ6APlCtQWo+BJdPlNyNvbf41QKCm PfMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=huhAwiohUqn/MgP4n2fw726XRYP2K7IGktEzcbmihf8=; b=S5O7IYsTSVLBW0uznDOmEdQAxzKR85jYlSN/sjDAX6X1K7oj1eVqxn7Os7K0++Jp+9 WSXeZaAH6ILjKa2/yGjI+Q2dmvkCM7Ynirm8WramKUYXp0K4ebS1pRDt3+fjP1AeSSIN EcdEU7CkExQerpeXUTm8m8dtIb6tqghZrpAfbUF0gfWBF9eiZ8opTBs08P8iUWPs4F7I 12z6lfCOoqpbiCo50RW32y0tSMQykvZ0q2r1wYPz5FpX3wuidK2SMR0eC2PbDiHdWGSs o/SvqUBbkbwxHPuTeT1KdNlcmob6Ll8Ww5NAg7uChO01UEvPxYwzZhkGNsygiBKxf5Q/ 4byA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=EmmaKeOo; dkim=pass header.i=@codeaurora.org header.s=default header.b=fCq7NEc6; 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 a1-v6si3461662plt.39.2018.05.16.14.14.16; Wed, 16 May 2018 14:14:30 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=EmmaKeOo; dkim=pass header.i=@codeaurora.org header.s=default header.b=fCq7NEc6; 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 S1752180AbeEPVOH (ORCPT + 99 others); Wed, 16 May 2018 17:14:07 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56172 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbeEPVOF (ORCPT ); Wed, 16 May 2018 17:14:05 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 58889601EA; Wed, 16 May 2018 21:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505245; bh=Qgze8UCV5jt2btaGAACCHJ+fSumcGMPLWpwAp1ZfVdo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EmmaKeOoixRAqQtg/oI92xOtGecdLOAxdhcJabDlst3y/7la+kVzY4vX9BGxnMVi2 3Vv3qalIHEbNiEGaTC7xG7vPbP9pOZX74KwHo4nviZeNGZPdPyqoPUKnINCibUUu+u mZVo0/CyTvSOXVCDOkU6XPE5Ejd9L+7cD202KWcE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 9ED866055C; Wed, 16 May 2018 21:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505244; bh=Qgze8UCV5jt2btaGAACCHJ+fSumcGMPLWpwAp1ZfVdo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fCq7NEc6kQS3OjAZiEj8KPZm8XKBnrwaNYl21ec8/G8p3yMwVyN2i3Lo7QZudcwXv h3qZ6NIt8Gn7lwJol4JRmOMcKHRq5l6AoPY8JAxesPFFeTGjQMyHRzoX0iUXCm9UOo xfL76YRQ9GSWzz4owyGo5BDOpv3BXF8MovoLIjsI= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 16 May 2018 14:14:04 -0700 From: Subhash Jadavani To: Asutosh Das Cc: cang@codeaurora.org, vivek.gautam@codeaurora.org, rnayak@codeaurora.org, vinholikatti@gmail.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org, Venkat Gopalakrishnan , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH v2 08/10] scsi: ufs: make sure all interrupts are processed In-Reply-To: References: Message-ID: X-Sender: subhashj@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-03 04:07, Asutosh Das wrote: > 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; > } Looks good to me. Reviewed-by: Subhash Jadavani -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project