Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3237783pxj; Mon, 24 May 2021 01:51:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfd0UPEvbNpXjPbGtyEmVw3q1Tlz1EtjvyM0kDzLfHMUVbT9ZqygGHKN+okd0dLE6g1OtY X-Received: by 2002:a05:6402:406:: with SMTP id q6mr24641836edv.110.1621846304594; Mon, 24 May 2021 01:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621846304; cv=none; d=google.com; s=arc-20160816; b=KilyzO852pbwzuKQ4QVQqqnlbnrE5EED0R6Tx1dYNfeyzRMKACtF8kLhahGZD0Pklc TeNUEe0cQCoTtt4lpNatIpsfUgn1PsiIWZJwTBHAUcyddcsthXveMUI7mO6zpS7cn+nm jvx6cGCAamqIEcuv/mQq1Bbky/3Eb5NJdnBSWLPpTAkLGKeubtUWCwcgG9EZnvGZhF8i BVCzdl0G4uXKicD0AIhIQTm99l8Llj5HKgol9WL9DfcrfrdEWDoyeEs80DbEVrqzSWkR E6Z+X+TiAPtljQREzd7cBRkbxn1Fc9124mHs3PHz8PCM1k1e77YMWYoSMwgvXw4x41Da SALA== 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=PU5Znia4RcEweLLvNYwLq0IHSXZDZZ8for3Q4Pnz+1I=; b=Ak1mxgDb9Byj37qW3gOYiHGIjocu08pQ+mE/KTWpQWMl9V48CIx+5Uazf1JmAp77ks j0AQleDK4PQwJcM1rMfR+GHXro5Gg1cQGV9q38s8rMRgkqst24tuG5Lx/SJ3fsvvL5IR 5PvLjpWloQiDjCzfyPJLQmTqmp6HChRQjKKus2T2fjBq8+pGTFvHsAh5EhsxK562BGR7 JmzfM9PgMxQVXsEYHXm6kykNjqUY+Src38geUdQVQ5IQTci9n2+SQOijK9mP8qCS5loO +rK4dZLChOk6AToD4jCcNCgedJnUu7y536P8KruPz6+yh5YTGgWrwGZChWi5g6WRwFkG hg2g== 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 s13si13743507edr.28.2021.05.24.01.51.22; Mon, 24 May 2021 01:51:44 -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 S232533AbhEXItb (ORCPT + 99 others); Mon, 24 May 2021 04:49:31 -0400 Received: from labrats.qualcomm.com ([199.106.110.90]:2199 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbhEXItW (ORCPT ); Mon, 24 May 2021 04:49:22 -0400 IronPort-SDR: 8JAQqg7qGTINxB9+J5SrY4UaW1sizO8+7wfumfx3jWTl9Y0IM+pt+Z1SNex1hixEuqueCzdzDV I1V+dGw8ts1JwyiYg3t+Jtr4quBZEEwPXuQKj+kTdqUulKBdoIbeqhoDW2MQ59Lqiw30ibaCvg wGcAVLfEdH4x+0XFYNV+9nj5mE8UWImdnKw5hhOll7cQU7iKpuakQA0hcwDQUbUzvJ0oq5gGC4 jGFk3EHr1kXFMgK/vgfRgV9rcZu0sSHO0W+z24LmgKCGUDASBlpCnNyI+qYlym9Uf9FtZeXfZe VVo= X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="47877521" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by labrats.qualcomm.com with ESMTP; 24 May 2021 01:47:52 -0700 X-QCInternal: smtphost Received: from wsp769891wss.qualcomm.com (HELO stor-presley.qualcomm.com) ([192.168.140.85]) by ironmsg02-sd.qualcomm.com with ESMTP; 24 May 2021 01:47:51 -0700 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 364CF21AD7; Mon, 24 May 2021 01:47:51 -0700 (PDT) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 5/6] scsi: ufs: Let host_sem cover the entire system suspend/resume Date: Mon, 24 May 2021 01:47:24 -0700 Message-Id: <1621846046-22204-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1621846046-22204-1-git-send-email-cang@codeaurora.org> References: <1621846046-22204-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 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5e6e3ac..9a3bc04 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9057,16 +9057,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) @@ -9099,7 +9096,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 @@ -9666,6 +9662,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); @@ -9692,6 +9689,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); -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.