Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1904271pxa; Mon, 3 Aug 2020 02:06:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVNZZS6anuhdS17/NMt7B5aA1Calp/pW+UIKdUTHhjPxIc6fCKcfM1rOWHzEt92cMgikuK X-Received: by 2002:a17:906:c799:: with SMTP id cw25mr16601140ejb.439.1596445602478; Mon, 03 Aug 2020 02:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596445602; cv=none; d=google.com; s=arc-20160816; b=X025teFVkRItMVmSFz8iqPhbNxURjhpWz3SLxiXD7YGS2+WY/aLksmX5dxqnYD8Vs4 C+LvqJt6hs615Q7VQrywe+MOIW6lWnl2dysJ/mY1KPM4bXUMxSVxP8Jxj6ijxbR1eQXX paEgz+IAYH1Qsk7nSmd1nLN6dIJOmrVKGarbWhssbo0tBUjWxJDoRoxRopQ2yl2VzrvB dPE3LoUbuYQlQUorG8dVwJkQTejrJ8zJ1lvN21bi0dKJ8Rqv+YHLY86PRa/RTKJQAw4n hiN4YIaKo/fUS1vKsLSQKzbUXNZx7ES9+tYdPHCCCXoFrY8WdQxfdhunmmUL2o431wbv sjlQ== 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:message-id:date :subject:cc:to:from:ironport-sdr; bh=slD5pqX0ck6h8nAjz1xhF/rQl8D7BLs0+6H4Snh1Rec=; b=m0BFHdhP3QF2Rgsxj0JpevxVXZgF74p8a/rH4KQNZuxk8n34RlcRPqm4/O/ApC+J4v 6Io/lVFgLBRKVqwy6fwK+i2AZJT2296v7e5cPEhwPDVEUDy4N/DNYwXp8jgG0T2CEpk2 M8DB0K6BWh7Lvuo+szsWWzBkPy++QfqhTr0PVIFB5gIRYy29/j5oxrpdqvtX4yaDf5+/ 3DYuIaDZqKBMh7i1Z5VyQ4fhJFnFTQ6zw7YuMDv8Kujc88+VjZGJcPp8Ek+nhW1GTJ+h XQnwPmUH0S6y8Z9QVAljvyuuC2dYtHf9b7uraW730pksvDdZocbT05ttCRrnUbxoz4+U h9MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si8149906ejh.441.2020.08.03.02.06.20; Mon, 03 Aug 2020 02:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbgHCJFY (ORCPT + 99 others); Mon, 3 Aug 2020 05:05:24 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:21494 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbgHCJFX (ORCPT ); Mon, 3 Aug 2020 05:05:23 -0400 IronPort-SDR: tiMR4BmNoE4dGZXEe91/ql5tjyhGGdcKzVBe6GFDh5EPp4+AcxMCmZLDPHJnWA+sOQv/ltA46z mU9ijqkmdMJlQJfcxSytc4TKkbX1cpn6x0No59DuvABy0CJ+EIcDljLzOIrkcvMfhgjml9fMSl ajgrm5HGIE0QMkK9vXIrj6WOxkgCAfyiY9pBjBzq7RDZj34UlBm2tXzcfjinD4Y5+jB4Vzkf5p XO9a9aETGR7DJVr6EFFR7BJ2Lnit4TMbXXnrQhbFIgsLKUTw9FOTtdAq3ZtR4U9mniBa1uo57M W9A= X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="47240958" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by labrats.qualcomm.com with ESMTP; 03 Aug 2020 02:05:21 -0700 Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg02-sd.qualcomm.com with ESMTP; 03 Aug 2020 02:05:20 -0700 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 0AB2A214E4; Mon, 3 Aug 2020 02:05:21 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Stanley Chu , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support) Subject: [PATCH v9 9/9] scsi: ufs: Properly release resources if a task is aborted successfully Date: Mon, 3 Aug 2020 02:04:44 -0700 Message-Id: <1596445485-19834-10-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596445485-19834-1-git-send-email-cang@codeaurora.org> References: <1596445485-19834-1-git-send-email-cang@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In current UFS task abort hook, namely ufshcd_abort(), if a task is aborted successfully, clock scaling busy time statistics is not updated and, most important, clk_gating.active_reqs is not decreased, which makes clk_gating.active_reqs stay above zero forever, thus clock gating would never happen. To fix it, instead of releasing resources "mannually", use the existing func __ufshcd_transfer_req_compl(). This can also eliminate racing of scsi_dma_unmap() from the real completion in IRQ handler path. Signed-off-by: Can Guo CC: Stanley Chu --- drivers/scsi/ufs/ufshcd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d7d2758..9a48389 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6635,11 +6635,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } - scsi_dma_unmap(cmd); - spin_lock_irqsave(host->host_lock, flags); - ufshcd_outstanding_req_clear(hba, tag); - hba->lrb[tag].cmd = NULL; + __ufshcd_transfer_req_compl(hba, (1UL << tag)); spin_unlock_irqrestore(host->host_lock, flags); out: -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.