Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5301390ybb; Tue, 24 Mar 2020 14:49:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vugkyq+lML+B9wF3h9v95cMPQgRZL+V/+5rCkSg4J8u0FT97HcEfGd7ErN+ZyIZPhR2HKlh X-Received: by 2002:aca:edcf:: with SMTP id l198mr254171oih.97.1585086559084; Tue, 24 Mar 2020 14:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585086559; cv=none; d=google.com; s=arc-20160816; b=AYF6L1M03mNxQxEoRhXKn+TN0M4enTpd5l4T0D11i46ibOnydn6lCX8hMp6T252y2a BPX3Uuz+gECiIavxB6OnMQwpvyTDw9e5JZyRbSH0UXMqIIX/D0YKgoGhzJH0Rk+8hjjK 6VI2JS1dQGbYjGWMC5ENmNDK1vMndql0xrdvKfKOXacOSs4vloz13YQRfJHq+8xKrsjd M+U+kM0KNLhWxVh+hOBTJSxwYwgrm1mpyOlkCrzsjc7VARUZd6x3GBukL22/ohPJMRXx h2Y50m2hXMh1s5ERyzNQ+uYb9dETdwv4EJTWVPEP2ty8pKJxrHnGIhpcmIqL4Z18yBgZ 1vQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=7b3yMiHik/VF7KwkGuCCqcI7P5EdMRp1FbRWEO7EQQ8=; b=Yf5ZAXuSQnfwLua6RzQUOHEc5qq1kp8XJLtUyJtn5w2VHKfH1LizsalQ6SEiIf4fio mjQVagjbvnDOC1Os5LvzGXJ4d0Gi6LhgL/dgHe1OAV4U1tPjjh58mg3cFqjboZ9kG0JS WPpjWkfB686HDpGZHrXmDpWc6ac/T481n7/54jd0EC11DfgXVKx7NtSMA/5yTx3hPPwz agXaZGYet/YWYUSPGICil0npZQ9MCfA41Lb7BVumS+MCVIyuTWIn62TPGACcKNTW711C PTg9eSMyUTXtj+IUOc4f3qsG2JWj8vPNum/8UoS31C6LJVL4xKgDBuboAqLZ6SoTHs1u 0ckw== ARC-Authentication-Results: i=1; mx.google.com; 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 a11si10053807otp.55.2020.03.24.14.49.06; Tue, 24 Mar 2020 14:49:19 -0700 (PDT) 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; 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 S1728241AbgCXVsi (ORCPT + 99 others); Tue, 24 Mar 2020 17:48:38 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:10335 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbgCXVsh (ORCPT ); Tue, 24 Mar 2020 17:48:37 -0400 Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 24 Mar 2020 14:48:36 -0700 Received: from asutoshd-linux1.qualcomm.com ([10.46.160.39]) by ironmsg02-sd.qualcomm.com with ESMTP; 24 Mar 2020 14:48:36 -0700 Received: by asutoshd-linux1.qualcomm.com (Postfix, from userid 92687) id D85431F79C; Tue, 24 Mar 2020 14:48:35 -0700 (PDT) From: Asutosh Das To: cang@codeaurora.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: Nitin Rawat , linux-arm-msm@vger.kernel.org, Asutosh Das , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Bean Huo , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [ 1/1] scsi: ufs: Resume ufs host before accessing ufs device Date: Tue, 24 Mar 2020 14:48:21 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nitin Rawat As a part of sysfs reading of descriptors/attributes/flags, query commands should only be executed when hba's power runtime status is active. To guarantee this, add pm_runtime_get/put_sync() to those paths where query commands are sent. Signed-off-by: Nitin Rawat Signed-off-by: Asutosh Das --- drivers/scsi/ufs/ufs-sysfs.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index dbdf8b0..92a63ee 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -210,8 +210,10 @@ static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba, if (param_size > 8) return -EINVAL; + pm_runtime_get_sync(hba->dev); ret = ufshcd_read_desc_param(hba, desc_id, desc_index, param_offset, desc_buf, param_size); + pm_runtime_put_sync(hba->dev); if (ret) return -EINVAL; switch (param_size) { @@ -558,6 +560,7 @@ static ssize_t _name##_show(struct device *dev, \ desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_ATOMIC); \ if (!desc_buf) \ return -ENOMEM; \ + pm_runtime_get_sync(hba->dev); \ ret = ufshcd_query_descriptor_retry(hba, \ UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE, \ 0, 0, desc_buf, &desc_len); \ @@ -574,6 +577,7 @@ static ssize_t _name##_show(struct device *dev, \ goto out; \ ret = snprintf(buf, PAGE_SIZE, "%s\n", desc_buf); \ out: \ + pm_runtime_put_sync(hba->dev); \ kfree(desc_buf); \ return ret; \ } \ @@ -604,9 +608,13 @@ static ssize_t _name##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ bool flag; \ + int ret; \ struct ufs_hba *hba = dev_get_drvdata(dev); \ - if (ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \ - QUERY_FLAG_IDN##_uname, &flag)) \ + pm_runtime_get_sync(hba->dev); \ + ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \ + QUERY_FLAG_IDN##_uname, &flag); \ + pm_runtime_put_sync(hba->dev); \ + if (ret) \ return -EINVAL; \ return sprintf(buf, "%s\n", flag ? "true" : "false"); \ } \ @@ -644,8 +652,12 @@ static ssize_t _name##_show(struct device *dev, \ { \ struct ufs_hba *hba = dev_get_drvdata(dev); \ u32 value; \ - if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, \ - QUERY_ATTR_IDN##_uname, 0, 0, &value)) \ + int ret; \ + pm_runtime_get_sync(hba->dev); \ + ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, \ + QUERY_ATTR_IDN##_uname, 0, 0, &value); \ + pm_runtime_put_sync(hba->dev); \ + if (ret) \ return -EINVAL; \ return sprintf(buf, "0x%08X\n", value); \ } \ @@ -766,9 +778,13 @@ static ssize_t dyn_cap_needed_attribute_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 (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, - QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value)) + pm_runtime_get_sync(hba->dev); + 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); + if (ret) return -EINVAL; return sprintf(buf, "0x%08X\n", value); } -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.