Received: by 10.223.176.5 with SMTP id f5csp2107758wra; Sun, 4 Feb 2018 20:57:50 -0800 (PST) X-Google-Smtp-Source: AH8x226W2GyBvZ40ndn43mtdg88rOEN7ZOdui0KPQtdgG80JkoFUq+OuXkjlG4Qhk9gw0/XH0xV0 X-Received: by 2002:a17:902:7c03:: with SMTP id x3-v6mr41088710pll.355.1517806670703; Sun, 04 Feb 2018 20:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517806670; cv=none; d=google.com; s=arc-20160816; b=WDunSPOSjBbiYPlB9FLczeUEtj5ahUsY/IcFqO0m/BUKQ1N9da1so/rWULBpVlQ0HH 652eFHjLQMD8SoRlrPShjhtEsdao1W81JjiZ4Vi4ke9LDuqONlZqAQtVgsaIm0+uIIct fpqoDWYObnFH5doqeEGvoBqySrMLOdizRmWy6WGNn3+eS0M2E755gW8YFKOrJ8xf4HYN cW8Hjz9ZJmall/2ZiGnPpnHR+1Fxk5X8jUP+mNcq77c0ItlwKDD6HW9APznE2lEHT+t+ wPbnJJuHxWWVw1xd+JcFul5+5FwTI3M5wenX8LB3BewI7OcusxKrxFNSsCyl6vWuVwKH yCBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=/QSRbNibaxZls5h0CLyMZ3yeKP0bAT++swIUmVoVefI=; b=LCtJw6NdMQjseYVzuK1pEncD+59X+MqOfp+lgaZDJCKLwecoYzXi81slME/uMffK92 VZhbwl+2OPGVQ6Go7eBMStrWbAS/8XpyuI4/ukVEONdCiNwXFp98VrXYXZlVVns4GK9G MZAy3ZNC6bFLgwQkp+RsdV3qhMpCHQrDCSd9eDXjfi2l2bYnez9U9TTOVHfuJcJ7dOob LzjPGGJEjJ9D6IvlBjfG8yiOVA484pWxNRFRKPqb5hKnRmYxaD797ndJ6kVOl46iQOKN +B968t0g6OX17LRMiAh09IsBflfDF0HSmntz89XMdLlduyjYes7tgSPga4fcVdhnddT5 g82w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NY/3p6xj; dkim=pass header.i=@codeaurora.org header.s=default header.b=WwDXjvfz; 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 s19-v6si2221203plp.116.2018.02.04.20.57.36; Sun, 04 Feb 2018 20:57:50 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=NY/3p6xj; dkim=pass header.i=@codeaurora.org header.s=default header.b=WwDXjvfz; 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 S1752532AbeBEE5O (ORCPT + 99 others); Sun, 4 Feb 2018 23:57:14 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:60494 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbeBEE5K (ORCPT ); Sun, 4 Feb 2018 23:57:10 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 70D03601C4; Mon, 5 Feb 2018 04:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517806629; bh=V3FBGoRh+7gyVb/66qJCvpdOVQMd5mCibYW09mSQQcc=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=NY/3p6xjzwUAg3FDg64CczX+ULaTtpNWVZjYb+s2NjTgvWwvoZ1UJUO8PaDY/ojBv mMS/uayTVPencnZmTqURYviFzbffu86S6NTtXUOX/ksJHb3s/zQ8D29Ap27CMsfBk9 dkkcPhnQXiFo70oMiATDvwaGqXXcKdbcZVYvSUg4= 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 [10.206.25.125] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 11B3F601C4; Mon, 5 Feb 2018 04:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517806628; bh=V3FBGoRh+7gyVb/66qJCvpdOVQMd5mCibYW09mSQQcc=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=WwDXjvfzKPvAsOBeBx0akdNDDIYXZ16dhxkrQ3ofojnqp2/YKaXsJKZMVqzZQbdMF Hp6k/I2vooXaxPmLApfjwvtAleGX9HBSNzOTuObLbRgGhgwTwIR1azelhsgpZ0gORH 8RGXRP6AknWaqGLNal2p3cQQsrDUnAEjAXk+5Ko0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11B3F601C4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH 1/1] scsi: ufs: make sure all interrupts are processed From: "Asutosh Das (asd)" To: Avri Altman , "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 , open list References: <1517288066-13171-1-git-send-email-asutoshd@codeaurora.org> <6ca20a27-3c10-bf0e-35e7-542b7ab77356@codeaurora.org> Message-ID: Date: Mon, 5 Feb 2018 10:27:02 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <6ca20a27-3c10-bf0e-35e7-542b7ab77356@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/2018 8:53 AM, Asutosh Das (asd) wrote: > On 1/31/2018 1:09 PM, Avri Altman wrote: >> Hi, >> Can you elaborate how this can even happen? >> Isn't the interrupt aggregation capability should attend for those cases? >> >> Thanks, >> Avri >> >>> -----Original Message----- >>> From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi- >>> owner@vger.kernel.org] On Behalf Of Asutosh Das >>> Sent: Tuesday, January 30, 2018 6:54 AM >>> 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 ; open >>> list >>> Subject: [PATCH 1/1] scsi: ufs: make sure all interrupts are processed >>> >>> 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. >> > > Hi > yes - interrupt aggregation makes sense here. But there were some > performance concerns with it; well, I don't have the data to back that > up now though. > However, I can code it up and check it. > Will post it in some time. > > -asd > Hi Avri, I went through the UFS HCI - v2.1 spec. Specifically, in sec 7.2.3 it explicitly mentions that the software should determine if new TRs were completed since the interrupt status was last read/cleared. This step is independent of aggregation. So I think the above implementation makes sense. Please let me know if I understood your concern correctly. -asd -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project