Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2147605ybx; Fri, 8 Nov 2019 00:18:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzcofXlVl4AdKLibiGZZncvXHYdkIgYdLbzkoOEPRrsYjBhqaFZyAR6u21f4QAVjR/BMAEd X-Received: by 2002:a50:85cb:: with SMTP id q11mr8494138edh.141.1573201133088; Fri, 08 Nov 2019 00:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573201133; cv=none; d=google.com; s=arc-20160816; b=kJBvRmpo0FXY3FeQiGjaIQ6Ln7CEH4RnbPV2cOdz6e5LxbJMlo+pNecv5xUKS+z7vP RiSaiudAUmoSk30CDgz/XnWhQNZDPI/Z8ZclTkrY0aEjGLEfCO4UyGwswIYCACX3Or1Q jq6x6MofHIIMv7PIIspKkLfbThKayq5emsLOixph4btZPou6lZLExFfHtUvrw4en0Q4t F5PxW9PcEemmF4IvPCSuv08UO+GKhq5+0wuSjsy7M8czVwC2Ph18YDcNis0r6J6/X7eX IXN6PEZxO88ubGSKekied9YVrpVhSs9KmkCKuqRKTaPbDKsoavNAwYyJT/IjB5VL1fkh SeZg== 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:dmarc-filter:dkim-signature:dkim-signature; bh=OArHu/4hO6YkVbNjxQPHM7+CIKluQNcfqzzy+ppVPTE=; b=okl3lh5SyCjn08yitya/5AIav+pmSMKMyiwWnEJQUVzMTqaFB5kbPF0l+8aW+BhN26 UAZ+Zr1D5SF5MWn3TuZSiS5AqfHtH4A3gOkVdRosAwsx5ToNtKtcVj37Sum3tqhZ+/mQ CJoAomHhVMxnXn68iunmB7EnLOCBuID4oxOpRTQTfsOX5yDkuA/ajRDE+aYbnYW5JGmF Ri05Ophmkv/boLRLYXcn35kG24qmsmd9ipWakOHox6PnKQngKFIPw8MTpjLerthyHy3b tnbffY3GgFprxOz6kJG/Nuez0o3WeYORKiXF/SM7gbzYKIsdgw3V128VqOkfhcOXr+6b 4exQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=TjNxE5sl; dkim=pass header.i=@codeaurora.org header.s=default header.b=mdJLYfvD; 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 ec22si3093464ejb.232.2019.11.08.00.18.29; Fri, 08 Nov 2019 00:18:53 -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=TjNxE5sl; dkim=pass header.i=@codeaurora.org header.s=default header.b=mdJLYfvD; 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 S1730745AbfKHIQX (ORCPT + 99 others); Fri, 8 Nov 2019 03:16:23 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50282 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727573AbfKHIQX (ORCPT ); Fri, 8 Nov 2019 03:16:23 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9F2D7608FF; Fri, 8 Nov 2019 08:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573200982; bh=YE4mTfL1gCRFuKHoeeEuCd7jY1kBHK31oyr+tOEAPfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TjNxE5sliFapWQiDw2tjpWK4diVD81tidrvLsZN04xBkXbyqQg245osh8j0WvyRFT obmkRzHZInO9aV54eEBuYua2WAhqMW5Hf0mYUygcwTrpPGxOZEt+Q3rfiAyMt7M4A0 1USSxCCVUCgjsZTNvXWj/AX9L2qK2GsFKd5vH4mU= 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.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id BDCDB60117; Fri, 8 Nov 2019 08:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573200977; bh=YE4mTfL1gCRFuKHoeeEuCd7jY1kBHK31oyr+tOEAPfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdJLYfvDzmqZJsbab5fIcgnplrHe06TgdDAckcjLofpkaj0rT7BUCOY9qoMMI5qhT VJpA5qEPyNv+CQ8G3/WjJYY10pzaNwQ46p4HVRX6xAVWByjc/QIqInTNq0Hf+xtu6T AA0hq2LO40+9TKfW4xeI7YCia+cE4gFEVGOd0KiA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BDCDB60117 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=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Subhash Jadavani , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 5/5] scsi: ufs: Complete pending requests in host reset and restore path Date: Fri, 8 Nov 2019 00:15:31 -0800 Message-Id: <1573200932-384-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573200932-384-1-git-send-email-cang@codeaurora.org> References: <1573200932-384-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 UFS host reset and restore path, before probe, we stop and start the host controller once. After host controller is stopped, the pending requests, if any, are cleared from the doorbell, but no completion IRQ would be raised due to the hba is stopped. These pending requests shall be completed along with the first NOP_OUT command(as it is the first command which can raise a transfer completion IRQ) sent during probe. Since the OCSs of these pending requests are not SUCCESS(because they are not yet literally finished), their UPIUs shall be dumped. When there are multiple pending requests, the UPIU dump can be overwhelming and may lead to stability issues because it is in atomic context. Therefore, before probe, complete these pending requests right after host controller is stopped. Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5950a7c..4df4136 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5404,8 +5404,8 @@ static void ufshcd_err_handler(struct work_struct *work) /* * if host reset is required then skip clearing the pending - * transfers forcefully because they will automatically get - * cleared after link startup. + * transfers forcefully because they will get cleared during + * host reset and restore */ if (needs_reset) goto skip_pending_xfer_clear; @@ -6333,9 +6333,13 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) int err; unsigned long flags; - /* Reset the host controller */ + /* + * Stop the host controller and complete the requests + * cleared by h/w + */ spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_hba_stop(hba, false); + ufshcd_complete_requests(hba); spin_unlock_irqrestore(hba->host->host_lock, flags); /* scale up clocks to max frequency before full reinitialization */ @@ -6369,7 +6373,6 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) static int ufshcd_reset_and_restore(struct ufs_hba *hba) { int err = 0; - unsigned long flags; int retries = MAX_HOST_RESET_RETRIES; do { @@ -6379,15 +6382,6 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba) err = ufshcd_host_reset_and_restore(hba); } while (err && --retries); - /* - * After reset the door-bell might be cleared, complete - * outstanding requests in s/w here. - */ - spin_lock_irqsave(hba->host->host_lock, flags); - ufshcd_transfer_req_compl(hba); - ufshcd_tmc_handler(hba); - spin_unlock_irqrestore(hba->host->host_lock, flags); - return err; } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project