Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2205165imu; Sat, 26 Jan 2019 23:09:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VbAjeovFyRWK4WzSHBg2G35W5QJGJkHvab+HLpyTVwNrHh2MIL7fuovrBm2nK1Zq/ye6D X-Received: by 2002:a63:5026:: with SMTP id e38mr15752770pgb.123.1548572978210; Sat, 26 Jan 2019 23:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548572978; cv=none; d=google.com; s=arc-20160816; b=xQuyzY8nU/y35pGkOM25y+H0AOxMVmtjgHsj4jutYnWhpsU6AxHJMzApXg+o7l1+d+ B7b31d6M6ZUxp5CIO5W7lg5pk5qRD4aejNCAxwUobid2XCPhEY++e7s7MGJ/GMtNVfGh 1js3CWfq6GexxfRwonP4vpjKA5RbX8TE2YOcOVQHAEq8ROy7JHTsAR8ie2+uoKho4O4p jl5VFz4P75TlcxUf/8SHO2kroody2nTHfTT9+iVMhM283higOSOWUPhBxqxeMklEX6rz Qt0RrjSkLJanAzcaCLIhLI+svTVCr3L1KnhfEkvvn2LL314s06Kv+7r1ujll8hbbJIt0 R6IA== 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:dkim-signature; bh=TNUVJXOecy1MYCnjCpYnuqgqhz84UfNjok+5KjDYZ3M=; b=EzOUEeJCoONEGzK1j/f3K3jIGfSDNV1Nb09JDOKfbcPpkR6I7t/uz+cqukkxfxVc5r cYq9mspDAuJj63ZwrhFnMd3pxQAu4wwSRHX3bOjK5NoU9rl2KqXzh+VYtMMrkPsTHKrn rlFZRAenXwZytOEBF5gCqbAxQy5sXhf2O+EFwR4nnzdFjdIkk584gUxrHY+cVPZ66ZdZ 2ah++BFihvrH202PRkS86VDv+Gt9at8Rzg27sH5RyhPXBIEfrngsOkxDw2dPqGXnuIK5 jp5DPjWSOtQqd4WfrSLN61YGfNP1fhnSu/qKSX7hzLdK9dJnri5fi34I8idYCTji/mTo spNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=PibYvW6p; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g19si12873886pgj.358.2019.01.26.23.09.23; Sat, 26 Jan 2019 23:09:38 -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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=PibYvW6p; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbfA0HIb (ORCPT + 99 others); Sun, 27 Jan 2019 02:08:31 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:4391 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbfA0HIb (ORCPT ); Sun, 27 Jan 2019 02:08:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1548572911; x=1580108911; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QxuRPPDSvUnjZmfzIphSkJNf+emFCuhe7yO3D1CmbuY=; b=PibYvW6pyf/DoPsCurOmo8nvdFV2YhgTebNGfw6Acu1PdEke/Dh7/qcz 82WVQb9JtfelCFixDEJN+1nBSWjLmHnGOLPly4pIs46mqPm3CoPIttbDj VPN8IXdy6TdKp0Mccu9NScC+tigT0xEXxK3WUO6ANxe4sYgTC2yxhi4an xr6Dxz/Bq/FebsItpX9K+ZvkFqiP9hKcbAK9U3wp5QGR0nJH/S7d3mmiC EBwWFAqOsSKlUQWnB1lpNKKuta++yVuS5XTnfkPrePW7+emmGirxcFFss zlvGz7DBHnz2pqpdT4KPXbHtAo7MvmEdeQx9tNRDtyVx5Y15LjT791cmy Q==; X-IronPort-AV: E=Sophos;i="5.56,529,1539619200"; d="scan'208";a="99875948" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 27 Jan 2019 15:08:31 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 26 Jan 2019 22:47:36 -0800 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.230.227]) by uls-op-cesaip02.wdc.com with ESMTP; 26 Jan 2019 23:08:28 -0800 From: Avri Altman To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Evan Green Cc: Avi Shchislowski , Alex Lemberg , Avri Altman Subject: [PATCH v4 2/3] scsi: ufs: Allow reading descriptor via raw upiu Date: Sun, 27 Jan 2019 09:07:47 +0200 Message-Id: <1548572868-12589-3-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548572868-12589-1-git-send-email-avri.altman@wdc.com> References: <1548572868-12589-1-git-send-email-avri.altman@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow to read descriptors via raw upiu. This in fact was forbidden just as a precaution, as ufs-bsg actually enforces which functionality is supported. Signed-off-by: Avri Altman Reviewed-by: Evan Green --- drivers/scsi/ufs/ufshcd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2ddf244..6b9ed21 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5775,6 +5775,20 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, /* just copy the upiu response as it is */ memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu)); + if (desc_buff && desc_op == UPIU_QUERY_OPCODE_READ_DESC) { + u8 *descp = (u8 *)lrbp->ucd_rsp_ptr + sizeof(*rsp_upiu); + u16 resp_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) & + MASK_QUERY_DATA_SEG_LEN; + + if (*buff_len >= resp_len) { + memcpy(desc_buff, descp, resp_len); + *buff_len = resp_len; + } else { + dev_warn(hba->dev, "rsp size is bigger than buffer"); + *buff_len = 0; + err = -EINVAL; + } + } ufshcd_put_dev_cmd_tag(hba, tag); wake_up(&hba->dev_cmd.tag_wq); @@ -5810,11 +5824,6 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, int ocs_value; u8 tm_f = be32_to_cpu(req_upiu->header.dword_1) >> 16 & MASK_TM_FUNC; - if (desc_buff && desc_op != UPIU_QUERY_OPCODE_WRITE_DESC) { - err = -ENOTSUPP; - goto out; - } - switch (msgcode) { case UPIU_TRANSACTION_NOP_OUT: cmd_type = DEV_CMD_TYPE_NOP; @@ -5855,7 +5864,6 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, break; } -out: return err; } -- 1.9.1