Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp214874pxj; Wed, 9 Jun 2021 21:47:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytqvUDpmo1+EkrYwCX5M30osDoFamStkEN9oNNo+cUqdQacvG/TE0ymjAb+fcjdQNPV+Ub X-Received: by 2002:a17:906:c1d2:: with SMTP id bw18mr2769512ejb.123.1623300479605; Wed, 09 Jun 2021 21:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623300479; cv=none; d=google.com; s=arc-20160816; b=mGwyI7oj/corpn5306I54rduLUR6Hi0h0FDvCsPzZqPGhuzdbTQj+AlL9C1slNMeA6 BQivE1F8/ghFTS+7n10MdnOJjXMj4p2CkejSMFvYm99Of4gWE+1Hfw3DP8sD4tNUj2gT VWxSL0vEVtB1/IIAwdKEbKLixyKsDwH2zv9CV3fdk8q3n7JVELMonX8b07zYY95U9vZk 64T108oIMatMqJ9Bx+uwul59K0Gm/P1Mubpdr6L/hYcQ3DmYvj184eKqWwBrUof/BIqg W8gtVbcUA0AvfafGT07q9P9tn9I4X6n1N+REsgYM6Spf9Zel2MPanp8h3KdBULIPIFRV r1og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr; bh=1prkHMqFRTuYq+3QdYiKw6UVJyLMD9VobbCJRBFuK9k=; b=yaAtZk576ylsquU+UOtU9VnuHgLIO821IFJfqjI2gE2xb2LIuBTC9AvYHqCz/Sgwm3 K8S5s27YIcTx9QRNyYhEqZwYykx1TnA6tjAH22ZPm7KcKklKiGps/SB2SCze+8AggYMn qsl6hzF1dHanB4f9maHUDt9WZ1Fw8eDuCuffMO8fwmsLSVFOotP/c7lFny1BH2XpLYZk NQHivYw8Nffrm4ih6IGXzkJp56JwapGT/Uq2exkAeOYrQ98Jcp/0NqpwqIyQFMkjHlpt ngxaUaxM+jGoqjQD8LGXK3xA4ECBw/BvFLQWeW/wua7owPj4BH7paj4qgvziRu00VXkM oCYQ== 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 m4si1568219edq.47.2021.06.09.21.47.36; Wed, 09 Jun 2021 21:47:59 -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 S230118AbhFJEqX (ORCPT + 99 others); Thu, 10 Jun 2021 00:46:23 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:10071 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbhFJEqW (ORCPT ); Thu, 10 Jun 2021 00:46:22 -0400 IronPort-SDR: jotiyUclQrVrtpwZwn2WtillfYGqVfOIO78rVhdw/eCjOS4N6HbAky4c/KrgKGFSTs9bTSX+aW EdCfJxiFQQuyNuJxR4t0sNRw8k6RlW0cslRBb+6+rAT+m7YOk7tlicH2hGPQPZ/NdAZb7qlCy/ fu1+7Y7V+fXXXu59R8erIui4jKxEYjcY9GduOfE/UFEKyKMoJzNzH8gXv1ElZocMPt3nOD7go1 npt/7KIKcuNL7ObbRHu7YTFAKAWgjviTMxE0uBl2/Rb1gEAp0RwqOfGtTQGsCRSKtqJf9TBUTG aW8= X-IronPort-AV: E=Sophos;i="5.83,262,1616482800"; d="scan'208";a="29778431" Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by labrats.qualcomm.com with ESMTP; 09 Jun 2021 21:44:26 -0700 X-QCInternal: smtphost Received: from wsp769891wss.qualcomm.com (HELO stor-presley.qualcomm.com) ([192.168.140.85]) by ironmsg01-sd.qualcomm.com with ESMTP; 09 Jun 2021 21:44:25 -0700 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id AFCF921AF7; Wed, 9 Jun 2021 21:44:25 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Jaegeuk Kim , Adrian Hunter , Kiwoong Kim , Satya Tangirala , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 7/9] scsi: ufs: Let host_sem cover the entire system suspend/resume Date: Wed, 9 Jun 2021 21:43:35 -0700 Message-Id: <1623300218-9454-8-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623300218-9454-1-git-send-email-cang@codeaurora.org> References: <1623300218-9454-1-git-send-email-cang@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org UFS error handling now is doing more than just re-probing, but also sending scsi cmds, e.g., for clearing UACs, and recovering runtime PM error, which may change runtime status of scsi devices. To protect system suspend/resume from being disturbed by error handling, move the host_sem from wl pm ops to ufshcd_suspend_prepare() and ufshcd_resume_complete(). Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 8 +++----- drivers/scsi/ufs/ufshcd.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c418a19..861942b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9060,16 +9060,13 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); - down(&hba->host_sem); if (pm_runtime_suspended(dev)) goto out; ret = __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM); - if (ret) { + if (ret) dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret); - up(&hba->host_sem); - } out: if (!ret) @@ -9102,7 +9099,6 @@ static int ufshcd_wl_resume(struct device *dev) hba->curr_dev_pwr_mode, hba->uic_link_state); if (!ret) hba->is_wl_sys_suspended = false; - up(&hba->host_sem); return ret; } #endif @@ -9665,6 +9661,7 @@ void ufshcd_resume_complete(struct device *dev) ufshcd_rpmb_rpm_put(hba); hba->rpmb_complete_put = false; } + up(&hba->host_sem); } EXPORT_SYMBOL_GPL(ufshcd_resume_complete); @@ -9691,6 +9688,7 @@ int ufshcd_suspend_prepare(struct device *dev) ufshcd_rpmb_rpm_get_sync(hba); hba->rpmb_complete_put = true; } + down(&hba->host_sem); return 0; } EXPORT_SYMBOL_GPL(ufshcd_suspend_prepare); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index eaebb4e..47da47c 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -693,7 +693,7 @@ struct ufs_hba_monitor { * @ee_ctrl_mask: Exception event control mask * @is_powered: flag to check if HBA is powered * @shutting_down: flag to check if shutdown has been invoked - * @host_sem: semaphore used to serialize concurrent contexts + * @host_sem: semaphore used to avoid concurrency of contexts * @eh_wq: Workqueue that eh_work works on * @eh_work: Worker to handle UFS errors that require s/w attention * @eeh_work: Worker to handle exception events -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.