From patchwork Fri Sep 21 09:44:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10609467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6089157B for ; Fri, 21 Sep 2018 09:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5E562DB87 for ; Fri, 21 Sep 2018 09:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A97952DB94; Fri, 21 Sep 2018 09:45:56 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 413342DB87 for ; Fri, 21 Sep 2018 09:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389537AbeIUPd6 (ORCPT ); Fri, 21 Sep 2018 11:33:58 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:49294 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389486AbeIUPd5 (ORCPT ); Fri, 21 Sep 2018 11:33:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1537523155; x=1569059155; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=AIN3TW3d8+zMeSheplQpMIP9tU1l0QDxcYiwNpSg0Oo=; b=TZ/2R+MsxymgpfJx3k70GqRF4aaIhYCh19hfenl5jSMhGs0s32UrAeU5 KChwTPP1E4H6LCU1ZKylHVGWuiZWOmJi9R/W9gM7ezHRmHLnmZDQc3Wgi 9vp4SH2bBmMGDIxyH4GjRAhH/mc65bXv14Sr3OdKgKErECfw2TmA/r7nP F8y/I+3FyniwW/Z3w8U/sKVtOveQMhzJQjmdMP5qNbdNdcY9Tk2dAZ/ZJ mt2jnav878g8ss4edlDmOukZR8pY5ujljarqPHdwMZnAuPaDyPvwGJgs8 1A5mztNncJWX+cvNOMZTRhzJOF3cIee0+jE69TuzAG6ceXxzLNwQ8kgKS A==; X-IronPort-AV: E=Sophos;i="5.54,284,1534780800"; d="scan'208";a="194511300" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 21 Sep 2018 17:45:55 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 21 Sep 2018 02:32:01 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip01.wdc.com with ESMTP; 21 Sep 2018 02:45:53 -0700 From: Avri Altman To: Christoph Hellwig , Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Cc: Stanislav Nijnikov , Avi Shchislowski , Alex Lemberg , Subhash Jadavani , Vinayak Holikatti , Avri Altman Subject: [PATCH v6 7/7] scsi: ufs-bsg: Add support for uic commands in ufs_bsg_request() Date: Fri, 21 Sep 2018 12:44:24 +0300 Message-Id: <1537523064-13478-8-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1537523064-13478-1-git-send-email-avri.altman@wdc.com> References: <1537523064-13478-1-git-send-email-avri.altman@wdc.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 Make ufshcd_send_uic_cmd() public for that. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufs_bsg.c | 11 ++++++++++- drivers/scsi/ufs/ufshcd.c | 4 ++-- drivers/scsi/ufs/ufshcd.h | 2 ++ include/uapi/scsi/scsi_bsg_ufs.h | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index c1797e2..b4261eb 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -55,6 +55,7 @@ static int ufs_bsg_request(struct bsg_job *job) unsigned int request_len = job->request_len; unsigned int reply_len = job->reply_len; struct utp_upiu_query *qr; + struct uic_command uc = {}; int msgcode; uint8_t *desc_buff = NULL; int desc_len = 0; @@ -107,7 +108,15 @@ static int ufs_bsg_request(struct bsg_job *job) break; case UPIU_TRANSACTION_UIC_CMD: - /* later */ + memcpy(&uc, &bsg_request->upiu_req.uc, UIC_CMD_SIZE); + ret = ufshcd_send_uic_cmd(hba, &uc); + if (ret) + dev_dbg(hba->dev, + "send uic cmd: error code %d\n", ret); + + memcpy(&bsg_reply->upiu_rsp.uc, &uc, UIC_CMD_SIZE); + + break; case UPIU_TRANSACTION_COMMAND: case UPIU_TRANSACTION_DATA_OUT: not_supported: diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f73edf9..61ee833 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2060,8 +2060,7 @@ static inline u8 ufshcd_get_upmcrs(struct ufs_hba *hba) * * Returns 0 only if success. */ -static int -ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) +int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { int ret; unsigned long flags; @@ -2081,6 +2080,7 @@ static inline u8 ufshcd_get_upmcrs(struct ufs_hba *hba) ufshcd_release(hba); return ret; } +EXPORT_SYMBOL_GPL(ufshcd_send_uic_cmd); /** * ufshcd_map_sg - Map scatter-gather list to prdt diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 2d5f3ee..e14c40f 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -813,6 +813,8 @@ extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val, u8 peer); extern int ufshcd_config_pwr_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *desired_pwr_mode); +extern int ufshcd_send_uic_cmd(struct ufs_hba *hba, + struct uic_command *uic_cmd); /* UIC command interfaces for DME primitives */ #define DME_LOCAL 0 diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h index 205b312..15b5226 100644 --- a/include/uapi/scsi/scsi_bsg_ufs.h +++ b/include/uapi/scsi/scsi_bsg_ufs.h @@ -13,6 +13,8 @@ #define MAX_CDB_SIZE 16 #define UPIU_TRANSACTION_UIC_CMD 0x1F +/* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */ +#define UIC_CMD_SIZE (sizeof(u32) * 4) enum { REQ_UPIU_SIZE_DWORDS = 8,