From patchwork Thu Feb 25 03:00:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Asutosh Das (asd)" X-Patchwork-Id: 12103161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95F95C433E0 for ; Thu, 25 Feb 2021 03:01:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54D8E64EA4 for ; Thu, 25 Feb 2021 03:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236902AbhBYDBX (ORCPT ); Wed, 24 Feb 2021 22:01:23 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:22187 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236898AbhBYDBW (ORCPT ); Wed, 24 Feb 2021 22:01:22 -0500 IronPort-SDR: A2p3YEObhS82c1WeKUAT+iVO3yw4sCqT63Kxd3oXH25fUejGwdeVKKASdE0G5eP4RRwgqks5wn CZmK870h8qkRJZJg4lG3fB7HGUpXqqVzc+H3XIgWxqGOezji6d8cgTBFyk4oR2pW8pgO7hLMuP U/uXFve3xiI0r50cyvtCuTau+pz74mJVz/o9ZXw2vtTHIHH6Uu1TN4M3YLmz4TVlUk3VSAe9GU nz3wMsmMtsHtoCWqwZ8A7/mAg30fund9R8sXN0+HMalDi3ii5sWchH6jDTOHnawyawsAdYCPKB Vd0= X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="47789821" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by labrats.qualcomm.com with ESMTP; 24 Feb 2021 19:00:39 -0800 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 Feb 2021 19:00:38 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 92687) id 555E821A29; Wed, 24 Feb 2021 19:00:38 -0800 (PST) From: Asutosh Das To: cang@codeaurora.org, martin.petersen@oracle.com, adrian.hunter@intel.com, linux-scsi@vger.kernel.org Cc: Asutosh Das , linux-arm-msm@vger.kernel.org, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Bean Huo , "Bao D. Nguyen" , Nitin Rawat , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 2/2] ufs: sysfs: Resume the proper scsi device Date: Wed, 24 Feb 2021 19:00:15 -0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Resumes the actual scsi device the unit descriptor of which is being accessed instead of the hba alone. Signed-off-by: Asutosh Das --- drivers/scsi/ufs/ufs-sysfs.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index acc54f5..34481e3 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -297,10 +297,10 @@ static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba, goto out; } - pm_runtime_get_sync(hba->dev); + scsi_autopm_get_device(hba->sdev_ufs_device); ret = ufshcd_read_desc_param(hba, desc_id, desc_index, param_offset, desc_buf, param_size); - pm_runtime_put_sync(hba->dev); + scsi_autopm_put_device(hba->sdev_ufs_device); if (ret) { ret = -EINVAL; goto out; @@ -678,7 +678,7 @@ static ssize_t _name##_show(struct device *dev, \ up(&hba->host_sem); \ return -ENOMEM; \ } \ - pm_runtime_get_sync(hba->dev); \ + scsi_autopm_get_device(hba->sdev_ufs_device); \ ret = ufshcd_query_descriptor_retry(hba, \ UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE, \ 0, 0, desc_buf, &desc_len); \ @@ -695,7 +695,7 @@ static ssize_t _name##_show(struct device *dev, \ goto out; \ ret = sysfs_emit(buf, "%s\n", desc_buf); \ out: \ - pm_runtime_put_sync(hba->dev); \ + scsi_autopm_put_device(hba->sdev_ufs_device); \ kfree(desc_buf); \ up(&hba->host_sem); \ return ret; \ @@ -744,10 +744,10 @@ static ssize_t _name##_show(struct device *dev, \ } \ if (ufshcd_is_wb_flags(QUERY_FLAG_IDN##_uname)) \ index = ufshcd_wb_get_query_index(hba); \ - pm_runtime_get_sync(hba->dev); \ + scsi_autopm_get_device(hba->sdev_ufs_device); \ ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \ QUERY_FLAG_IDN##_uname, index, &flag); \ - pm_runtime_put_sync(hba->dev); \ + scsi_autopm_put_device(hba->sdev_ufs_device); \ if (ret) { \ ret = -EINVAL; \ goto out; \ @@ -813,10 +813,10 @@ static ssize_t _name##_show(struct device *dev, \ } \ if (ufshcd_is_wb_attrs(QUERY_ATTR_IDN##_uname)) \ index = ufshcd_wb_get_query_index(hba); \ - pm_runtime_get_sync(hba->dev); \ + scsi_autopm_get_device(hba->sdev_ufs_device); \ ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, \ QUERY_ATTR_IDN##_uname, index, 0, &value); \ - pm_runtime_put_sync(hba->dev); \ + scsi_autopm_put_device(hba->sdev_ufs_device); \ if (ret) { \ ret = -EINVAL; \ goto out; \ @@ -899,11 +899,15 @@ static ssize_t _pname##_show(struct device *dev, \ struct scsi_device *sdev = to_scsi_device(dev); \ struct ufs_hba *hba = shost_priv(sdev->host); \ u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \ + int ret; \ if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun, \ _duname##_DESC_PARAM##_puname)) \ return -EINVAL; \ - return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \ + scsi_autopm_get_device(sdev); \ + ret = ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \ lun, _duname##_DESC_PARAM##_puname, buf, _size); \ + scsi_autopm_put_device(sdev); \ + return ret; \ } \ static DEVICE_ATTR_RO(_pname) @@ -964,10 +968,10 @@ static ssize_t dyn_cap_needed_attribute_show(struct device *dev, goto out; } - pm_runtime_get_sync(hba->dev); + scsi_autopm_get_device(hba->sdev_ufs_device); ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value); - pm_runtime_put_sync(hba->dev); + scsi_autopm_put_device(hba->sdev_ufs_device); if (ret) { ret = -EINVAL; goto out;