From patchwork Thu Aug 6 05:06:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11702757 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66BB4175A for ; Thu, 6 Aug 2020 11:04:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F27822DFB for ; Thu, 6 Aug 2020 11:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbgHFFHM (ORCPT ); Thu, 6 Aug 2020 01:07:12 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:4057 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728276AbgHFFHF (ORCPT ); Thu, 6 Aug 2020 01:07:05 -0400 IronPort-SDR: QLVrMAOEpUUgTjsvYyz0a51seXYBaPgpETDw5Qyl6hTyOv4IIZ0wZ/qjPIR84Fc21aFvbVtmyy bY7wkePJzez75bac8OW0bapsr7te5gNNUn/bGjLTXw6D6PmAZdokjkkc7OfI1zIE/B0w69d87H vCnncy80cu+7lr6wWFN7WE42ysz6wOPpgDSpWX29+4BIZOWojIOjmyEvxUTrKg98Y30hTy5n8B z0HhIL06ehxA3n3QqHRNhicrvwgJ7odwX55ya8llmBmvXVWVY+lK/TlLfNKLIlxcTpb8pggV7e I4E= X-IronPort-AV: E=Sophos;i="5.75,440,1589266800"; d="scan'208";a="29068261" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by labrats.qualcomm.com with ESMTP; 05 Aug 2020 22:07:04 -0700 Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg02-sd.qualcomm.com with ESMTP; 05 Aug 2020 22:07:03 -0700 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 06A2621562; Wed, 5 Aug 2020 22:07:04 -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 9/9] scsi: ufs: Properly release resources if a task is aborted successfully Date: Wed, 5 Aug 2020 22:06:20 -0700 Message-Id: <1596690383-16438-10-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596690383-16438-1-git-send-email-cang@codeaurora.org> References: <1596690383-16438-1-git-send-email-cang@codeaurora.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 Reviewed-by: Stanley Chu diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b2947ab..9541fc7 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6636,11 +6636,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: