From patchwork Mon Nov 7 19:53:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Winkler, Tomas" X-Patchwork-Id: 9415841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69E3D60512 for ; Mon, 7 Nov 2016 18:59:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AA2528D1D for ; Mon, 7 Nov 2016 18:59:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F89628D35; Mon, 7 Nov 2016 18:59:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06B8928D1D for ; Mon, 7 Nov 2016 18:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933497AbcKGS61 (ORCPT ); Mon, 7 Nov 2016 13:58:27 -0500 Received: from mga09.intel.com ([134.134.136.24]:35275 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932980AbcKGS6Y (ORCPT ); Mon, 7 Nov 2016 13:58:24 -0500 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 07 Nov 2016 10:57:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,606,1473145200"; d="scan'208";a="188665252" Received: from twinkler-lnx.jer.intel.com ([10.12.87.167]) by fmsmga004.fm.intel.com with ESMTP; 07 Nov 2016 10:57:40 -0800 From: Tomas Winkler To: Greg Kroah-Hartman , Ulf Hansson , Adrian Hunter , James Bottomley , "Martin K . Petersen" , Vinayak Holikatti , Andy Lutomirski , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Michael Ryleev , Joao Pinto , Christoph Hellwig , Yaniv Gardi Cc: Avri Altman , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-doc@vger.kernel.org, Tomas Winkler , Alexander Usyskin Subject: [PATCH v7 10/11] scsi: ufs: retrieve rpmb rw size Date: Mon, 7 Nov 2016 21:53:13 +0200 Message-Id: <1478548394-8184-11-git-send-email-tomas.winkler@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478548394-8184-1-git-send-email-tomas.winkler@intel.com> References: <1478548394-8184-1-git-send-email-tomas.winkler@intel.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Retrieve maximum number of RPMB frames that can be in a single request. Currently the limitations is provided only for writes via reliable_wr_cnt API. V7: New in the series Signed-off-by: Tomas Winkler Signed-off-by: Alexander Usyskin --- drivers/scsi/ufs/ufs.h | 6 ++++++ drivers/scsi/ufs/ufshcd.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 845b874e2977..84bb8d7c6b63 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -176,6 +176,12 @@ enum ufs_desc_max_size { QUERY_DESC_RFU_MAX_SIZE = 0x00, }; +enum geometry_desc_param_offset { + GEOMETRY_DESC_LEN = 0x0, + GEOMETRY_DESC_TYPE = 0x1, + GEOMETRY_DESC_RPMB_RW_SIZE = 0x17, +}; + /* Unit descriptor parameters offsets in bytes*/ enum unit_desc_param { UNIT_DESC_PARAM_LEN = 0x0, diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 95bb9dc7fbfe..69f5b03f6774 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2196,6 +2196,15 @@ static inline int ufshcd_read_unit_desc_param(struct ufs_hba *hba, param_offset, param_read_buf, param_size); } +static inline int ufshcd_read_geometry_desc_param(struct ufs_hba *hba, + enum geometry_desc_param_offset param_offset, + u8 *param_read_buf, u32 param_size) +{ + return ufshcd_read_desc_param(hba, QUERY_DESC_IDN_GEOMETRY, 0, + param_offset, param_read_buf, param_size); +} + + /** * ufshcd_memory_alloc - allocate memory for host memory space data structures * @hba: per adapter instance @@ -4896,6 +4905,19 @@ static struct rpmb_ops ufshcd_rpmb_dev_ops = { static inline void ufshcd_rpmb_add(struct ufs_hba *hba) { struct rpmb_dev *rdev; + u8 rw_size; + int ret; + + ret = ufshcd_read_geometry_desc_param(hba, GEOMETRY_DESC_RPMB_RW_SIZE, + &rw_size, sizeof(rw_size)); + if (ret) { + dev_warn(hba->dev, "%s: cannot get rpmb rw limit %d\n", + dev_name(hba->dev), ret); + /* fallback to singel frame write */ + rw_size = 1; + } + + ufshcd_rpmb_dev_ops.reliable_wr_cnt = rw_size; scsi_device_get(hba->sdev_ufs_rpmb); rdev = rpmb_dev_register(hba->dev, &ufshcd_rpmb_dev_ops);