Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp264060imp; Tue, 19 Feb 2019 23:13:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYVBhWpfs79UqJhmHDjlgUAFbLHTgiaQbArfNIwSf4Y3nodB8+lJnfLzdRGK+PG7CEVk7VY X-Received: by 2002:a17:902:4324:: with SMTP id i33mr34586589pld.227.1550646786261; Tue, 19 Feb 2019 23:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550646786; cv=none; d=google.com; s=arc-20160816; b=rXsWGcECOkh2R1C1Tih4L3McpUAJpaImDq/eZ90WEoHHHCHJ+h+Ej1d3XUNrrulCNk EpD/nSkcEwyZ26iE6V5BHxn9mWS8/+0M9edi5a/eM6yPzg59r2r8wzUgDD+qZg0bTppK V564gu2HJvHPApYRXMQ4SNMI6m66SQS63q+Ziknzhz/xGhcsC+XHHV4tjQ8GbJtgHdYh mIiPHKObqea1CQuAQimBEwdxwFvu6dgniBvWQo+gYI6BJgyj8p7GYLYb7EBnLo38IqNg 1FgBf7NpFjG3mQQ7M4p41swBUErbPdNcZc1Rx/G0LqruMwKG8XIOdakwz5dfKAbRL5Ck Xi3w== 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=jAUJ4vFopEWSi2iWOQszVLQuKPVup+6vAwIh1+yEvYA=; b=YU2iqLf6I4HOKoCqkVkEfYRK+x6ygtNttf6IC0nNRe3pYmINUAQ9HM9Ouj33yV2Tg/ sOCaf3dua5dTKpW/XHfQNjhMcNtsQ4JQsAoNbhoF5yNixtpTNejrGhGLL42CbzRm/mrD bf04YS14YWRGD3/DHFMcRx0QyudN3KG75MJP7hMy7KmEvkPLQl8yAvdjBo8UqqdPQY8h R2PtgyE77zrS/y3gxnRmWRYd2njg7boAP1er7tRY3egfkkS2JYDdjffbUdcjvWxkpkqf LixyQ/z6MmxAa8jpT79U4CUFDR8xK8fJ40RyT2YfmvRiCu3DFGDLT5jmYo7BePukHAg4 hbKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=So0YMxkZ; 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 cs11si8039757plb.248.2019.02.19.23.12.51; Tue, 19 Feb 2019 23:13:06 -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=So0YMxkZ; 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 S1730507AbfBTHMB (ORCPT + 99 others); Wed, 20 Feb 2019 02:12:01 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:24914 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbfBTHMB (ORCPT ); Wed, 20 Feb 2019 02:12:01 -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=1550646721; x=1582182721; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Tk5/ymUCtSagdiY+kvSyhh1HiqyYgHHb0Vp1thsVv9g=; b=So0YMxkZ5+v2cucnjv7HGJIdID/6kBtEkATBBWJU/mvEp/1csw9KXivp Errwy3MkBxY4qjjB1NV0E+9M2YYKasG8J1OboN/DTJ8ZxsHvK9H1Rw6Hx p2qjLacc1MUtM6pST0LpfkEa3V6Tut9Gzw+ShoecjBEXbvWpvccK6z5u5 VHr2wOc5fognVCBMqWlnUJ6kGkIRv7+lvgOIXlYFrzhY78GRgZDHgKZjM S6ukazeTVIpAVaV3h/b5Z+wytIGDD+a1hZKo5pfKls8DXAoS/klHPD9ft //r1Tsw89MJjbqcizyJ5wQyWjB7yc9Gec+sbaPwkdj3ognVRy+XqkqDeK w==; X-IronPort-AV: E=Sophos;i="5.58,388,1544457600"; d="scan'208";a="103461522" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2019 15:12:00 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 19 Feb 2019 22:50:23 -0800 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.230.227]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Feb 2019 23:11:58 -0800 From: Avri Altman To: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Evan Green , Bean Huo , Pedro Sousa , Alim Akhtar Cc: Avi Shchislowski , Alex Lemberg , Avri Altman Subject: [REPOST PATCH v4 2/3] scsi: ufs: Allow reading descriptor via raw upiu Date: Wed, 20 Feb 2019 09:11:13 +0200 Message-Id: <1550646674-15258-3-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550646674-15258-1-git-send-email-avri.altman@wdc.com> References: <1550646674-15258-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 Reviewed-by: Bean Huo --- 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 5ca4581..7b5b601 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5780,6 +5780,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); @@ -5815,11 +5829,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; @@ -5860,7 +5869,6 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, break; } -out: return err; } -- 1.9.1