From patchwork Mon Sep 3 10:33:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585741 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 1CB1914E0 for ; Mon, 3 Sep 2018 10:34:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C6228417 for ; Mon, 3 Sep 2018 10:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1D4029580; Mon, 3 Sep 2018 10:34:13 +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 B9AEF29443 for ; Mon, 3 Sep 2018 10:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726153AbeICOxj (ORCPT ); Mon, 3 Sep 2018 10:53:39 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:44741 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbeICOxj (ORCPT ); Mon, 3 Sep 2018 10:53:39 -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=1535970846; x=1567506846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XuSOPMZgw7sQQ1wQHzvSpcs59lyNxuCBDHc7SnHqn1E=; b=Qs0bQHoU1fdIbDVv3VPkUbHiOvOlvZtsDErdhWE0iPU/y9acvoDe1aCQ C0QKJY05Dv99pjtYCFeeoh69wGV9WlLdm0YSd3z1A++vpCEK73fa+oZIh LuxYIY8Z8sB+f7WUEssBjhlJgPaQ3Gvbi8uD5JDQR77L/0+PMz964y1Tq ltEo3cRazrCdKr79QWydYR+lnrZrdGuL4T1Lybm7NtmNA1xT1w3Ye+2ku LytA0kwMbq/BgeZ1x1oLE8dZKux0ync6/vNhrN9xzA40FXqCtCrXj50Fd +jLIl2sjm2hOZtrqGCOVY9Y3q20m9m0DNkK3pAk75BQ2lBwVFHS5DBCSm g==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="193059727" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:34:05 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 03 Sep 2018 03:20:49 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:02 -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 v3 1/7] scsi: ufs: Add ufs-bsg module Date: Mon, 3 Sep 2018 13:33:10 +0300 Message-Id: <1535970796-25582-2-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> MIME-Version: 1.0 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 Add a bsg endpoint that supports UPIUs. For now, just provide an API to allocate and remove ufs-bsg node. We will use this framework to manage ufs devices by sending UPIU transactions. For the time being, implements an empty bsg_request() - will add some more functionality in coming patches. Nonetheless, we reveal here the protocol we are planning to use: UFS Transport Protocol Transactions. UFS transactions consist of packets called UFS Protocol Information Units (UPIU). There are UPIU’s defined for UFS SCSI commands, responses, data in and data out, task management, utility functions, vendor functions, transaction synchronization and control, and more. By using UPIUs, we get access to the most fine-grained internals of this protocol, and able to communicate with the device in ways, that are sometimes beyond the capacity of the ufs driver. Moreover and as a result, our core structure - ufs_bsg_node has a pretty lean structure: using upiu transactions that contains the outmost detailed info, so we don't really need complex constructs to support it. Signed-off-by: Avri Altman --- drivers/scsi/ufs/Kconfig | 19 +++++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ufs_bsg.c | 173 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufs_bsg.h | 70 ++++++++++++++++ include/uapi/scsi/scsi_bsg_ufs.h | 56 +++++++++++++ 5 files changed, 319 insertions(+) create mode 100644 drivers/scsi/ufs/ufs_bsg.c create mode 100644 drivers/scsi/ufs/ufs_bsg.h create mode 100644 include/uapi/scsi/scsi_bsg_ufs.h diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index e09fe6a..83ba979 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -109,3 +109,22 @@ config SCSI_UFS_HISI Select this if you have UFS controller on Hisilicon chipset. If unsure, say N. + +config SCSI_UFS_BSG + bool "Universal Flash Storage BSG device node" + depends on SCSI_UFSHCD + select BLK_DEV_BSGLIB + help + Universal Flash Storage (UFS) is SCSI transport specification for + accessing flash storage on digital cameras, mobile phones and + consumer electronic devices. + An UFS controller communicates with an UFS device by exchanging + UFS Protocol Information Units (UPIUs). + UPIUs can not only be used as a transport layer for the SCSI protocol + but are also used by the UFS native command set. + This transport driver supports exchanging UFS protocol information units + with an UFS device. See also the ufshcd driver, which is a SCSI driver + that supports UFS devices. + + Select this if you need a bsg device node for your UFS controller. + If unsure, say N. diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile index 2c50f03..8f7138a 100644 --- a/drivers/scsi/ufs/Makefile +++ b/drivers/scsi/ufs/Makefile @@ -8,3 +8,4 @@ ufshcd-core-objs := ufshcd.o ufs-sysfs.o obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o +obj-$(CONFIG_SCSI_UFS_BSG) += ufs_bsg.o diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c new file mode 100644 index 0000000..b099ee2 --- /dev/null +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * bsg endpoint that supports UPIUs + * + * Copyright (C) 2018 Western Digital Corporation + */ +#include "ufs_bsg.h" + +struct ufs_bsg_node { + struct device dev; + struct request_queue *q; +}; + +struct ufs_bsg { + struct ufs_hba *hba; + struct ufs_bsg_node *node; +}; +static struct ufs_bsg *bsg_host; + +static inline struct ufs_bsg_node *dev_to_ufs_node(struct device *d) +{ + return container_of(d, struct ufs_bsg_node, dev); +} + +static int ufs_bsg_request(struct bsg_job *job) +{ + struct ufs_bsg_request *bsg_request = job->request; + struct ufs_bsg_reply *bsg_reply = job->reply; + int ret = -ENOTSUPP; + + bsg_reply->reply_payload_rcv_len = 0; + + /* Do Nothing for now */ + dev_err(job->dev, "unsupported message_code 0x%x\n", + bsg_request->msgcode); + + bsg_reply->result = ret; + if (ret) + job->reply_len = sizeof(uint32_t); + else + job->reply_len = sizeof(struct ufs_bsg_reply) + + bsg_reply->reply_payload_rcv_len; + + bsg_job_done(job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); + + return ret; +} + +static void ufs_bsg_node_delete(struct ufs_bsg_node *node) +{ + struct device *dev = &node->dev; + + if (node->q) + bsg_unregister_queue(node->q); + + device_del(dev); + + put_device(dev); +} + +/** + * ufs_bsg_remove - detach and remove the added ufs-bsg node + * + * Should be called when unloading the driver. + */ +void ufs_bsg_remove(void) +{ + if (!bsg_host) + return; + + if (bsg_host->node) + ufs_bsg_node_delete(bsg_host->node); + + kfree(bsg_host); +} + +static void ufs_bsg_node_release(struct device *dev) +{ + struct ufs_bsg_node *node = dev_to_ufs_node(dev); + + put_device(dev->parent); + kfree(node); +} + +static struct ufs_bsg_node *ufs_bsg_node_alloc(struct Scsi_Host *shost) +{ + struct ufs_bsg_node *node; + struct device *parent = &shost->shost_gendev; + + node = kzalloc(sizeof(*node), GFP_KERNEL); + if (!node) + return NULL; + + device_initialize(&node->dev); + + node->dev.parent = get_device(parent); + node->dev.release = ufs_bsg_node_release; + + dev_set_name(&node->dev, "ufs-bsg-%d:0", shost->host_no); + + return node; +} + +static int ufs_bsg_initialize(struct Scsi_Host *shost, + struct ufs_bsg_node *node) +{ + struct request_queue *q; + + q = bsg_setup_queue(&node->dev, dev_name(&node->dev), + ufs_bsg_request, 0); + if (IS_ERR(q)) + return PTR_ERR(q); + node->q = q; + + return 0; +} + +static int ufs_bsg_node_add(struct ufs_bsg_node *node) +{ + struct device *dev = &node->dev; + struct Scsi_Host *shost = dev_to_shost(dev->parent); + int error; + + error = device_add(dev); + if (error) + return error; + + if (ufs_bsg_initialize(shost, node)) + dev_err(dev, "fail to initialize a bsg dev %d\n", + shost->host_no); + + return 0; +} + +/** + * ufs_bsg_probe - Add ufs bsg device node + * @hba: per adapter object + * + * Called during initial loading of the driver, and before scsi_scan_host. + */ +int ufs_bsg_probe(struct ufs_hba *hba) +{ + struct ufs_bsg_node *node; + int ret; + + bsg_host = kzalloc(sizeof(*bsg_host), GFP_KERNEL); + if (!bsg_host) { + ret = -ENOMEM; + goto out; + } + + node = ufs_bsg_node_alloc(hba->host); + if (!node) { + ret = -ENOMEM; + goto out_free_bsg_host; + } + + ret = ufs_bsg_node_add(node); + if (ret) + goto out_free_node; + + bsg_host->node = node; + bsg_host->hba = hba; + + return 0; + +out_free_node: + put_device(&node->dev); +out_free_bsg_host: + kfree(bsg_host); +out: + return ret; +} diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs/ufs_bsg.h new file mode 100644 index 0000000..58eda73 --- /dev/null +++ b/drivers/scsi/ufs/ufs_bsg.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2018 Western Digital Corporation + */ +#ifndef UFS_BSG_H +#define UFS_BSG_H + +#include +#include +#include + +#include +#include "ufshcd.h" +#include "ufs.h" + +#define UPIU_TRANSACTION_UIC_CMD 0x1F + +enum { + REQ_UPIU_SIZE_DWORDS = 8, + RSP_UPIU_SIZE_DWORDS = 8, +}; + +struct ufs_bsg_request { + uint32_t msgcode; + struct utp_upiu_header header; + union { + struct utp_upiu_query qr; + struct utp_upiu_task_req tr; + /* use utp_upiu_query to host the 4 dwords of uic command */ + struct utp_upiu_query uc; + } tsf; +}; + + +struct ufs_bsg_reply { + /* + * The completion result. Result exists in two forms: + * if negative, it is an -Exxx system errno value. There will + * be no further reply information supplied. + * else, it's the 4-byte scsi error result, with driver, host, + * msg and status fields. The per-msgcode reply structure + * will contain valid data. + */ + uint32_t result; + + /* If there was reply_payload, how much was received? */ + uint32_t reply_payload_rcv_len; + + struct utp_upiu_header header; + union { + struct utp_upiu_query qr; + struct utp_upiu_task_rsp tr; + struct utp_upiu_query uc; + } tsf; +}; + +struct ufs_bsg_raw_upiu { + struct ufs_bsg_upiu request; + struct ufs_bsg_upiu reply; +}; + +#ifdef CONFIG_SCSI_UFS_BSG +void ufs_bsg_remove(void); +int ufs_bsg_probe(struct ufs_hba *hba); +#else +static inline void ufs_bsg_remove(void) {} +static inline int ufs_bsg_probe(struct ufs_hba *hba) {return 0; } +#endif + +#endif /* UFS_BSG_H */ diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h new file mode 100644 index 0000000..5fb37be --- /dev/null +++ b/include/uapi/scsi/scsi_bsg_ufs.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * UFS Transport SGIO v4 BSG Message Support + * + * Copyright (C) 2018 Western Digital Corporation + */ +#ifndef SCSI_BSG_UFS_H +#define SCSI_BSG_UFS_H + +/* + * This file intended to be included by both kernel and user space + */ + + +/** + * struct ufs_bsg_upiu - upiu transaction structure + * + * @header: upiu header + * @tsf: Transaction Specific Fields + * @data: payload pointer + * + * This structure supports all ufs transaction types per JEDEC UFSv2.1 + * paragraph 10.7 + */ +struct ufs_bsg_upiu { + uint32_t header[3]; + uint32_t tsf[5]; + uint8_t data[0]; +}; + +/* request (CDB) structure of the sg_io_v4 */ +struct ufs_bsg_upiu_request { + uint32_t msgcode; + struct ufs_bsg_upiu upiu; +} __packed; + +/* response (request sense data) structure of the sg_io_v4 */ +struct ufs_bsg_upiu_reply { + /* + * The completion result. Result exists in two forms: + * if negative, it is an -Exxx system errno value. There will + * be no further reply information supplied. + * else, it's the 4-byte scsi error result, with driver, host, + * msg and status fields. The per-msgcode reply structure + * will contain valid data. + */ + uint32_t result; + + /* If there was reply_payload, how much was recevied ? */ + uint32_t reply_payload_rcv_len; + + struct ufs_bsg_upiu upiu; + +}; + +#endif /* SCSI_BSG_UFS_H */ From patchwork Mon Sep 3 10:33:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585743 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 B09C6139B for ; Mon, 3 Sep 2018 10:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA9928417 for ; Mon, 3 Sep 2018 10:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93D6929580; Mon, 3 Sep 2018 10:34:17 +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 4C52428417 for ; Mon, 3 Sep 2018 10:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbeICOxt (ORCPT ); Mon, 3 Sep 2018 10:53:49 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:40626 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbeICOxt (ORCPT ); Mon, 3 Sep 2018 10:53:49 -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=1535970857; x=1567506857; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=fiKQneGop4YgoHbnq+WNmnWKS1FvBww1rf/oFE/F/E8=; b=K6nmjx+5LTSxueyA2aBKtAqCy+HEX5+nZHIpTHLNmuqUhJ1JWiXNOceK YiiefXlreFkkDKM++6jC0ZRz4z1U4ol2t/beO70t6AIl7Z8dgT7AqeDPr 6LMliJuH7ilvfpUk4HoWVjUmjDfgcVLFNHHyxwCEtkBzRuYHcCTSmN9hR aZxBbJACL1bWJLJNVkXoTfgJHV8COD79mXXGZXBUn2MkIhu6zVucZEjc7 pdQmcUJ9VP0Y5g9LLl4OjPpsEthBougO2DDZIym+wGqsRZYQcPRjgR00A 2ysiblKZHeXhRVVPgzWh93sq16sLDzG02CBgO7ymEYRxHbraT4EcOB/vJ g==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="90486136" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:34:17 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Sep 2018 03:21:06 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:12 -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 v3 2/7] scsi: ufs: Instantiate a ufs bsg if its available Date: Mon, 3 Sep 2018 13:33:11 +0300 Message-Id: <1535970796-25582-3-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 Call the probe/remove APIs. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9d5d2ca..ed37914 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -46,6 +46,7 @@ #include "ufs_quirks.h" #include "unipro.h" #include "ufs-sysfs.h" +#include "ufs_bsg.h" #define CREATE_TRACE_POINTS #include @@ -6652,6 +6653,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba) hba->clk_scaling.is_allowed = true; } + ufs_bsg_probe(hba); + scsi_scan_host(hba->host); pm_runtime_put_sync(hba->dev); } @@ -7875,6 +7878,7 @@ int ufshcd_shutdown(struct ufs_hba *hba) */ void ufshcd_remove(struct ufs_hba *hba) { + ufs_bsg_remove(); ufs_sysfs_remove_nodes(hba->dev); scsi_remove_host(hba->host); /* disable interrupts */ From patchwork Mon Sep 3 10:33:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585747 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 B30DE16B1 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2AC928417 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9671029580; Mon, 3 Sep 2018 10:34:39 +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 3795D28417 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbeICOyL (ORCPT ); Mon, 3 Sep 2018 10:54:11 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:12524 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbeICOyL (ORCPT ); Mon, 3 Sep 2018 10:54:11 -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=1535970878; x=1567506878; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=nSsH9LIq/OUFlw5q2Ou2KZ1ZKZ3a2EcKy2577WwjVmY=; b=nZXgbdJos4oHKZIHpcKrE+bz0+kHuGZZxP/k4l29WB5nX7Vur8pu4Zow 0vh1P/pAQyKg0CEK5S+pBOC/W0iNBATy6qZPMqAkG+TWZ06AZRMkNF0ds A2OKnz5SY6zKOGTj2VeryKJHS+Hrjmb69xm5UKKPqkjKs0nIvCUC3+0a1 y17SrBvc6uBdX0eWQPIIUd1BBaLADy82n7c/Y4GEBPNYoHPt7eKE6Hs9C AXXnoN7e0Goomw3B9anpf7n3wbReWiNN4Qx92GIIe8FyGD9qiMZLgteGq iVmom5fmFr8T/qJO46f8b64SM5NTKalr4F0924ixVIag4UgABvC1St6AF Q==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="89873743" 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; 03 Sep 2018 18:34:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Sep 2018 03:21:16 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:22 -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 v3 3/7] scsi: ufs: Add fill task management request Date: Mon, 3 Sep 2018 13:33:12 +0300 Message-Id: <1535970796-25582-4-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 Do that in preparation to re-use ufshcd_issue_tm_cmd code. Signed-off-by: Avri Altman Signed-off-by: Christoph Hellwig --- drivers/scsi/ufs/ufshcd.c | 50 +++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ed37914..d18832a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5598,6 +5598,32 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) return err; } +static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, + int lun_id, int task_id, u8 tm_function, + int task_tag) +{ + struct utp_upiu_task_req *task_req_upiup; + + /* Configure task request descriptor */ + task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); + task_req_descp->header.dword_2 = + cpu_to_le32(OCS_INVALID_COMMAND_STATUS); + + task_req_upiup = + (struct utp_upiu_task_req *)task_req_descp->task_req_upiu; + task_req_upiup->header.dword_0 = + UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0, lun_id, + task_tag); + task_req_upiup->header.dword_1 = UPIU_HEADER_DWORD(0, tm_function, 0, + 0); + /* + * The host shall provide the same value for LUN field in the basic + * header and for Input Parameter. + */ + task_req_upiup->input_param1 = cpu_to_be32(lun_id); + task_req_upiup->input_param2 = cpu_to_be32(task_id); +} + /** * ufshcd_issue_tm_cmd - issues task management commands to controller * @hba: per adapter instance @@ -5612,7 +5638,6 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, u8 tm_function, u8 *tm_response) { struct utp_task_req_desc *task_req_descp; - struct utp_upiu_task_req *task_req_upiup; struct Scsi_Host *host; unsigned long flags; int free_slot; @@ -5632,27 +5657,10 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, spin_lock_irqsave(host->host_lock, flags); task_req_descp = hba->utmrdl_base_addr; task_req_descp += free_slot; - - /* Configure task request descriptor */ - task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); - task_req_descp->header.dword_2 = - cpu_to_le32(OCS_INVALID_COMMAND_STATUS); - - /* Configure task request UPIU */ - task_req_upiup = - (struct utp_upiu_task_req *) task_req_descp->task_req_upiu; task_tag = hba->nutrs + free_slot; - task_req_upiup->header.dword_0 = - UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0, - lun_id, task_tag); - task_req_upiup->header.dword_1 = - UPIU_HEADER_DWORD(0, tm_function, 0, 0); - /* - * The host shall provide the same value for LUN field in the basic - * header and for Input Parameter. - */ - task_req_upiup->input_param1 = cpu_to_be32(lun_id); - task_req_upiup->input_param2 = cpu_to_be32(task_id); + + ufshcd_fill_tm_req(task_req_descp, lun_id, task_id, tm_function, + task_tag); ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function); From patchwork Mon Sep 3 10:33:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585745 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 2229C14E0 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1063628417 for ; Mon, 3 Sep 2018 10:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0485229580; Mon, 3 Sep 2018 10:34:39 +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 90C6028417 for ; Mon, 3 Sep 2018 10:34:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726157AbeICOyK (ORCPT ); Mon, 3 Sep 2018 10:54:10 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:44796 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbeICOyK (ORCPT ); Mon, 3 Sep 2018 10:54:10 -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=1535970878; x=1567506878; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LM2NgZmChPUzjf2QEmFWBwFMjsVAJStrTUorC/lzHaA=; b=gVGg80GUpCy5cve5OJgC+KT5zmrzWFmTIQusPuf2xtbEbFq6pvDd+N/w OjQ82IHsSgNri6PT7sMEq+eR7IoMC7KfqhvYJ9PPpMseQqUJP81yy0k2v MoSdPPpyAaXLLwJ4WxyhpoBslbAQoKqCtA3H7yRXMtdzgXr62TyKeJW2Y z5uXc2uz2oSZ1FQLkoShHXi2ZD5vS8kibXnuu5mZPATJrTasTC/udiY+G QXfmdYyf3rG8uPYxvA6B3ULEKHGL4ugf5e5wQLgtErt7MUUWOqo6oRxmL XydlnvBQkRpHnU7n16h3+XYaZ5uPGZVcMGWTmK6wTm3A3EuxFEgcPrkWA g==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="193059830" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:34:37 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 03 Sep 2018 03:21:21 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:34 -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 v3 4/7] scsi: ufs: Allow ufshcd_issue_tm_cmd accept raw task upius Date: Mon, 3 Sep 2018 13:33:13 +0300 Message-Id: <1535970796-25582-5-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 Do that in order to re-use its code if the task request and response UPIUs are given externally. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d18832a..15be103 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5599,6 +5599,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) } static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, + struct utp_upiu_task_req *raw_task_req_upiup, int lun_id, int task_id, u8 tm_function, int task_tag) { @@ -5609,6 +5610,13 @@ static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, task_req_descp->header.dword_2 = cpu_to_le32(OCS_INVALID_COMMAND_STATUS); + if (raw_task_req_upiup) { + raw_task_req_upiup->header.dword_0 |= cpu_to_be32(task_tag); + memcpy(task_req_descp->task_req_upiu, raw_task_req_upiup, + GENERAL_UPIU_REQUEST_SIZE); + return; + } + task_req_upiup = (struct utp_upiu_task_req *)task_req_descp->task_req_upiu; task_req_upiup->header.dword_0 = @@ -5634,8 +5642,11 @@ static void ufshcd_fill_tm_req(struct utp_task_req_desc *task_req_descp, * * Returns non-zero value on error, zero on success. */ -static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, - u8 tm_function, u8 *tm_response) +static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, + struct utp_upiu_task_req *raw_task_req_upiup, + struct utp_upiu_task_req *raw_task_rsp_upiup, + int lun_id, int task_id, u8 tm_function, + u8 *tm_response) { struct utp_task_req_desc *task_req_descp; struct Scsi_Host *host; @@ -5659,8 +5670,8 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, task_req_descp += free_slot; task_tag = hba->nutrs + free_slot; - ufshcd_fill_tm_req(task_req_descp, lun_id, task_id, tm_function, - task_tag); + ufshcd_fill_tm_req(task_req_descp, raw_task_req_upiup, lun_id, task_id, + tm_function, task_tag); ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function); @@ -5692,6 +5703,10 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, err = -ETIMEDOUT; } else { err = ufshcd_task_req_compl(hba, free_slot, tm_response); + if (raw_task_rsp_upiup) + memcpy(raw_task_rsp_upiup, + task_req_descp->task_rsp_upiu, + GENERAL_UPIU_REQUEST_SIZE); ufshcd_add_tm_upiu_trace(hba, task_tag, "tm_complete"); } @@ -5726,7 +5741,8 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) tag = cmd->request->tag; lrbp = &hba->lrb[tag]; - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp); + err = ufshcd_issue_tm_cmd(hba, NULL, NULL, lrbp->lun, 0, + UFS_LOGICAL_RESET, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) err = resp; @@ -5856,8 +5872,9 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) } for (poll_cnt = 100; poll_cnt; poll_cnt--) { - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, - UFS_QUERY_TASK, &resp); + err = ufshcd_issue_tm_cmd(hba, NULL, NULL, lrbp->lun, + lrbp->task_tag, UFS_QUERY_TASK, + &resp); if (!err && resp == UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED) { /* cmd pending in the device */ dev_err(hba->dev, "%s: cmd pending in the device. tag = %d\n", @@ -5895,8 +5912,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } - err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag, - UFS_ABORT_TASK, &resp); + err = ufshcd_issue_tm_cmd(hba, NULL, NULL, lrbp->lun, lrbp->task_tag, + UFS_ABORT_TASK, &resp); if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) { if (!err) { err = resp; /* service response error */ From patchwork Mon Sep 3 10:33:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585749 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 A3CFD139B for ; Mon, 3 Sep 2018 10:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9037829443 for ; Mon, 3 Sep 2018 10:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84A592958C; Mon, 3 Sep 2018 10:34:49 +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 DA38C29443 for ; Mon, 3 Sep 2018 10:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbeICOyV (ORCPT ); Mon, 3 Sep 2018 10:54:21 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:40659 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbeICOyV (ORCPT ); Mon, 3 Sep 2018 10:54:21 -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=1535970889; x=1567506889; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=/k9hMbIFquW6/YtPVmaUjFRFsJKDFQnMcwxmqsxsVjQ=; b=i/1bZP7IggdzYjemVW1ieexEvUFc6XF6qxybdvoVxq1nqpAg2Blqmlqv 0/9M2ienx4hHiSjiWllCG/iBLAq8xPhVvspaD5kRY2plC5Tn74CNDLasj ulfLFUCELez5p5uUu85jOW2W/cL+Alcn8nhVXYS3WVxOE2T2Tp6GIXFxx bB+WTBKtB1oTZ9Nv9dhPCNLx2g8CpdEZ2CYKDUHbZN7yYh1W5eBZpu1IA 1Zy5TLyeUq4SCNM57V48Kij6oibseD3PoVKkjCZ0FItTsA2P5J6SykYUT e2tbYigHto5hyiuFayKSHyGd1rowHeJcXBnzy45nukpyPlXWxctu+2aHJ A==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="90486167" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:34:48 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Sep 2018 03:21:38 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:44 -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 v3 5/7] scsi: ufs: Add API to execute raw upiu commands Date: Mon, 3 Sep 2018 13:33:14 +0300 Message-Id: <1535970796-25582-6-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 The UFS host software uses a combination of a host register set, and Transfer Request Descriptors in system memory to communicate with host controller hardware. In its mmio space, a separate places are assigned to UTP Transfer Request Descriptor ("utrd") list, and to UTP Task Management Request Descriptor ("utmrd") list. The provided API supports utrd-typed requests: nop out and device management commands. It also supports utmrd-type requests: task management requests. Other UPIU types are not supported for now. We utilize the already existing code for tag and task work queues. That is, all utrd-typed UPIUs are "disguised" as device management commands. Similarly, the utmrd-typed UPUIs uses the task management infrastructure. It is up to the caller to fill the upiu request properly, as it will be copied without any further input validations. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 6 ++ 2 files changed, 160 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 15be103..3618be0 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -257,6 +257,8 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool on, static irqreturn_t ufshcd_intr(int irq, void *__hba); static int ufshcd_change_power_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *pwr_mode); +static int ufshcd_task_req_compl(struct ufs_hba *hba, u32 index, u8 *resp); + static inline bool ufshcd_valid_tag(struct ufs_hba *hba, int tag) { return tag >= 0 && tag < hba->nutrs; @@ -5719,6 +5721,158 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, } /** + * ufshcd_issue_devman_upiu_cmd - API for sending "utrd" type requests + * @hba: per-adapter instance + * @req_upiu: upiu request + * @rsp_upiu: upiu reply + * @msgcode: message code, one of UPIU Transaction Codes Initiator to Target + * @desc_buff: pointer to descriptor buffer, NULL if NA + * @buff_len: descriptor size, 0 if NA + * @rw: either READ or WRITE + * + * Those type of requests uses UTP Transfer Request Descriptor - utrd. + * Therefore, it "rides" the device management infrastructure: uses its tag and + * tasks work queues. + * + * Since there is only one available tag for device management commands, + * the caller is expected to hold the hba->dev_cmd.lock mutex. + */ +static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, + struct utp_upiu_req *req_upiu, + struct utp_upiu_req *rsp_upiu, + u8 *desc_buff, int *buff_len, + int cmd_type, int rw) +{ + struct ufshcd_lrb *lrbp; + int err = 0; + int tag; + struct completion wait; + unsigned long flags; + u32 upiu_flags; + u8 *descp; + + down_read(&hba->clk_scaling_lock); + + wait_event(hba->dev_cmd.tag_wq, ufshcd_get_dev_cmd_tag(hba, &tag)); + + init_completion(&wait); + lrbp = &hba->lrb[tag]; + WARN_ON(lrbp->cmd); + + lrbp->cmd = NULL; + lrbp->sense_bufflen = 0; + lrbp->sense_buffer = NULL; + lrbp->task_tag = tag; + lrbp->lun = 0; + lrbp->command_type = hba->ufs_version == UFSHCI_VERSION_10 || + hba->ufs_version == UFSHCI_VERSION_11 ? + UTP_CMD_TYPE_DEV_MANAGE : + UTP_CMD_TYPE_UFS_STORAGE; + lrbp->intr_cmd = true; + hba->dev_cmd.type = cmd_type; + + /* update the task tag in the request upiu */ + req_upiu->header.dword_0 |= cpu_to_be32(tag); + + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE); + + /* just copy the upiu request as it is */ + memcpy(lrbp->ucd_req_ptr, req_upiu, GENERAL_UPIU_REQUEST_SIZE); + + if (desc_buff && rw == WRITE) { + descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE; + memcpy(descp, desc_buff, *buff_len); + *buff_len = 0; + } + + memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); + + hba->dev_cmd.complete = &wait; + + /* Make sure descriptors are ready before ringing the doorbell */ + wmb(); + spin_lock_irqsave(hba->host->host_lock, flags); + ufshcd_send_command(hba, tag); + spin_unlock_irqrestore(hba->host->host_lock, flags); + + /* + * ignore the returning value here - ufshcd_check_query_response is + * bound to fail since dev_cmd.query and dev_cmd.type were left empty. + * read the response directly ignoring all errors. + */ + ufshcd_wait_for_dev_cmd(hba, lrbp, QUERY_REQ_TIMEOUT); + + /* just copy the upiu request as it is */ + memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, GENERAL_UPIU_REQUEST_SIZE); + + ufshcd_put_dev_cmd_tag(hba, tag); + wake_up(&hba->dev_cmd.tag_wq); + up_read(&hba->clk_scaling_lock); + return err; +} + +/** + * ufshcd_exec_raw_upiu_cmd - API function for sending raw upiu commands + * @hba: per-adapter instance + * @req_upiu: upiu request + * @rsp_upiu: upiu reply - only 8 DW as we do not support scsi commands + * @msgcode: message code, one of UPIU Transaction Codes Initiator to Target + * @desc_buff: pointer to descriptor buffer, NULL if NA + * @buff_len: descriptor size, 0 if NA + * @rw: either READ or WRITE + * + * Supports UTP Transfer requests (nop and query), and UTP Task + * Management requests. + * It is up to the caller to fill the upiu conent properly, as it will + * be copied without any further input validations. + */ +int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, + struct utp_upiu_req *req_upiu, + struct utp_upiu_req *rsp_upiu, + int msgcode, + u8 *desc_buff, int *buff_len, int rw) +{ + int err; + int cmd_type = DEV_CMD_TYPE_QUERY; + u8 resp = 0xF; + + if (desc_buff && rw == READ) { + err = -ENOTSUPP; + goto out; + } + + switch (msgcode) { + case UPIU_TRANSACTION_NOP_OUT: + cmd_type = DEV_CMD_TYPE_NOP; + /* fall through */ + case UPIU_TRANSACTION_QUERY_REQ: + ufshcd_hold(hba, false); + mutex_lock(&hba->dev_cmd.lock); + err = ufshcd_issue_devman_upiu_cmd(hba, req_upiu, rsp_upiu, + desc_buff, buff_len, + cmd_type, rw); + mutex_unlock(&hba->dev_cmd.lock); + ufshcd_release(hba); + + break; + case UPIU_TRANSACTION_TASK_REQ: + err = ufshcd_issue_tm_cmd(hba, + (struct utp_upiu_task_req *)req_upiu, + (struct utp_upiu_task_req *)rsp_upiu, + 0, 0, 0, &resp); + + break; + default: + err = -EINVAL; + + break; + } + +out: + return err; +} + +/** * ufshcd_eh_device_reset_handler - device reset handler registered to * scsi layer. * @cmd: SCSI command pointer diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 33fdd3f..0e8e50a 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -892,6 +892,12 @@ int ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba); +int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, + struct utp_upiu_req *req_upiu, + struct utp_upiu_req *rsp_upiu, + int msgcode, + u8 *desc_buff, int *buff_len, int rw); + /* Wrapper functions for safely calling variant operations */ static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) { From patchwork Mon Sep 3 10:33:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585751 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 DDAB414E0 for ; Mon, 3 Sep 2018 10:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9A5729580 for ; Mon, 3 Sep 2018 10:35:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDDCE29590; Mon, 3 Sep 2018 10:35:02 +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 A722429580 for ; Mon, 3 Sep 2018 10:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbeICOye (ORCPT ); Mon, 3 Sep 2018 10:54:34 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:40669 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbeICOye (ORCPT ); Mon, 3 Sep 2018 10:54:34 -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=1535970902; x=1567506902; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=2hE796bj/qbXsYYd0OPSH/pl2fnPvnviL/SveNEL7hA=; b=PShtNikoo72OoZ9Sf/7uevCvKih463mRRmuiJTAKnO687SDMGGiclGRC kHjmBDqpfnEjt5/EuP0mG3tFoRLUCkLD+0wejOFcuw5ekKuw7UyPooMHh LSStuKq/eI++P8Qun2JvrtVXf6Azux1OqJWYgbF4q0U31T0Ke4Hz1GGWr rEsRtE1I0Qb7O+So2NZ/TmJtu7fMVhz49GJ3l6zLl/Qhr+ww19I0pBR2d CL6LdZ1Mhhdsw60GME6J6MCv7jqeed00DSPQ7Qg6B9vTXqTXt5oGXvrHe pymU4nzlFwkIDXX9wzO49AKusQxrfHyOvRvXZaszyk2Yu8i2o8HFnd6bQ w==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="90486173" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:35:01 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 03 Sep 2018 03:21:44 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:34:56 -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 v3 6/7] scsi: ufs-bsg: Add support for raw upiu in ufs_bsg_request() Date: Mon, 3 Sep 2018 13:33:15 +0300 Message-Id: <1535970796-25582-7-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 Do that for the currently supported UPIUs: query, nop out, and task management. We do not support UPIU of type scsi command yet, while we are using the job's request and reply pointers to hold the payload. We will look into it in later patches. We might need to elaborate the raw upiu api for that. We also still not supporting uic commands: For first phase, we plan to use the existing api, and send only uic commands that are already supported. Anyway, all that will come in the next patch. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufs_bsg.c | 118 +++++++++++++++++++++++++++++++++++++++++++-- drivers/scsi/ufs/ufs_bsg.h | 1 + 2 files changed, 115 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index b099ee2..8c9167d 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -22,18 +22,128 @@ static inline struct ufs_bsg_node *dev_to_ufs_node(struct device *d) return container_of(d, struct ufs_bsg_node, dev); } +static int ufs_bsg_get_query_desc_size(struct utp_upiu_query *qr, + int *desc_len) +{ + int desc_size = be16_to_cpu(qr->length); + int desc_id = qr->idn; + int ret = 0; + + if (qr->opcode != UPIU_QUERY_OPCODE_WRITE_DESC || desc_size <= 0) + return -EINVAL; + + ret = ufshcd_map_desc_id_to_length(bsg_host->hba, desc_id, desc_len); + + if (ret || !*desc_len) + return -EINVAL; + + *desc_len = min_t(int, *desc_len, desc_size); + + return ret; +} + +static int ufs_bsg_verify_query_size(unsigned int request_len, + unsigned int reply_len, + int rw, int desc_len) +{ + int min_req_len = sizeof(struct ufs_bsg_request); + int min_rsp_len = sizeof(struct ufs_bsg_reply); + + if (rw == WRITE) + min_req_len += desc_len; + + if (min_req_len > request_len) + return -EINVAL; + + if (min_rsp_len > reply_len) + return -EINVAL; + + return 0; +} + static int ufs_bsg_request(struct bsg_job *job) { struct ufs_bsg_request *bsg_request = job->request; struct ufs_bsg_reply *bsg_reply = job->reply; - int ret = -ENOTSUPP; + unsigned int request_len = job->request_len; + unsigned int reply_len = job->reply_len; + struct utp_upiu_query *qr; + struct utp_upiu_req *req_upiu = NULL; + struct utp_upiu_req *rsp_upiu = NULL; + int msgcode; + uint8_t *desc_buff = NULL; + int desc_len = 0; + int rw = UFS_BSG_NOP; + int ret; + ret = ufs_bsg_verify_query_size(request_len, reply_len, rw, desc_len); + if (ret) { + dev_err(job->dev, "not enough space assigned\n"); + goto out; + } bsg_reply->reply_payload_rcv_len = 0; - /* Do Nothing for now */ - dev_err(job->dev, "unsupported message_code 0x%x\n", - bsg_request->msgcode); + msgcode = bsg_request->msgcode; + switch (msgcode) { + case UPIU_TRANSACTION_QUERY_REQ: + qr = &bsg_request->tsf.qr; + if (qr->opcode == UPIU_QUERY_OPCODE_READ_DESC) + goto not_supported; + + if (ufs_bsg_get_query_desc_size(qr, &desc_len)) + goto null_desc_buff; + + if (qr->opcode == UPIU_QUERY_OPCODE_WRITE_DESC) { + rw = WRITE; + desc_buff = ((uint8_t *)bsg_request) + + sizeof(struct ufs_bsg_request); + } + +null_desc_buff: + /* fall through */ + case UPIU_TRANSACTION_NOP_OUT: + case UPIU_TRANSACTION_TASK_REQ: + /* Now that we know if its a read or write, verify again */ + if (rw != UFS_BSG_NOP || desc_len) { + ret = ufs_bsg_verify_query_size(request_len, reply_len, + rw, desc_len); + if (ret) { + dev_err(job->dev, + "not enough space assigned\n"); + goto out; + } + } + + req_upiu = (struct utp_upiu_req *)&bsg_request->header; + rsp_upiu = (struct utp_upiu_req *)&bsg_reply->header; + ret = ufshcd_exec_raw_upiu_cmd(bsg_host->hba, + req_upiu, rsp_upiu, msgcode, + desc_buff, &desc_len, rw); + + break; + case UPIU_TRANSACTION_UIC_CMD: + /* later */ + case UPIU_TRANSACTION_COMMAND: + case UPIU_TRANSACTION_DATA_OUT: +not_supported: + /* for the time being, we do not support data transfer upiu */ + ret = -ENOTSUPP; + dev_err(job->dev, "unsupported msgcode 0x%x\n", msgcode); + + break; + default: + ret = -EINVAL; + + break; + } + + /* + * As we do not support read descriptor, the returning + * reply_payload_rcv_len is always 0. + */ + bsg_reply->reply_payload_rcv_len = 0; +out: bsg_reply->result = ret; if (ret) job->reply_len = sizeof(uint32_t); diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs/ufs_bsg.h index 58eda73..9cc71bc 100644 --- a/drivers/scsi/ufs/ufs_bsg.h +++ b/drivers/scsi/ufs/ufs_bsg.h @@ -13,6 +13,7 @@ #include "ufshcd.h" #include "ufs.h" +#define UFS_BSG_NOP (-1) #define UPIU_TRANSACTION_UIC_CMD 0x1F enum { From patchwork Mon Sep 3 10:33:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10585753 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 B9C21139B for ; Mon, 3 Sep 2018 10:35:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6AF028417 for ; Mon, 3 Sep 2018 10:35:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99AE429580; Mon, 3 Sep 2018 10:35:12 +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 3538C28417 for ; Mon, 3 Sep 2018 10:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbeICOyo (ORCPT ); Mon, 3 Sep 2018 10:54:44 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:40688 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbeICOyo (ORCPT ); Mon, 3 Sep 2018 10:54:44 -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=1535970912; x=1567506912; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=DRxyUcQJX914dINw5sPaHTKjpvLxipso5+MSGNRlwo4=; b=SFWGnxS3yYgUTqnVo8+KumNiSYKCGpwCUww43rwUrKtUr7nUNz7CkNw9 c6bqsprmhJu6VNMBw9D22puXN/q0E7tM7lj7/GaNnMe66To80GkU6JSlo c1rBxxxlxVYMKxuItzlF0sO0cHusyWeeMASoAv9VtrDLfdF0RVgD/sggn dHy6kUZATB0pY6+9wvaNkef7SSh82qIkGZUrDk6p+BsEvvtSkPrdxP+je XeehL9kIL6lkJ88PmF6OTzBF4XkhZYwaQVKtmgVTVoGiaK4fho+nM+bdp 4F7yvFr8r7O9jTc9DLWlVCoC08bUO0BJTft+fx2LuVkQ4qQKx9babWX7f Q==; X-IronPort-AV: E=Sophos;i="5.53,324,1531756800"; d="scan'208";a="90486177" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Sep 2018 18:35:12 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 03 Sep 2018 03:21:55 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Sep 2018 03:35:07 -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 v3 7/7] scsi: ufs-bsg: Add support for uic commands in ufs_bsg_request() Date: Mon, 3 Sep 2018 13:33:16 +0300 Message-Id: <1535970796-25582-8-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535970796-25582-1-git-send-email-avri.altman@wdc.com> References: <1535970796-25582-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 Add support to those uic commands, that are currently supported by ufshcd api: the variants of dme_{peer}_{set_get}. At this point better not to add any new api, as careless uic command may turn the device into a brick. Signed-off-by: Avri Altman --- drivers/scsi/ufs/ufs_bsg.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/ufs/ufs_bsg.h | 2 ++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index 8c9167d..d1255be 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -61,6 +61,55 @@ static int ufs_bsg_verify_query_size(unsigned int request_len, return 0; } +static int ufs_bsg_exec_uic_cmd(struct uic_command *uc) +{ + u32 attr_sel = uc->argument1; + u8 attr_set = (uc->argument2 >> 16) & 0xff; + u32 mib_val = uc->argument3; + int cmd = uc->command; + int ret = 0; + + switch (cmd) { + case UIC_CMD_DME_GET: + ret = ufshcd_dme_get_attr(bsg_host->hba, attr_sel, + &mib_val, DME_LOCAL); + break; + case UIC_CMD_DME_SET: + ret = ufshcd_dme_set_attr(bsg_host->hba, attr_sel, attr_set, + mib_val, DME_LOCAL); + break; + case UIC_CMD_DME_PEER_GET: + ret = ufshcd_dme_get_attr(bsg_host->hba, attr_sel, + &mib_val, DME_PEER); + break; + case UIC_CMD_DME_PEER_SET: + ret = ufshcd_dme_set_attr(bsg_host->hba, attr_sel, attr_set, + mib_val, DME_PEER); + break; + case UIC_CMD_DME_POWERON: + case UIC_CMD_DME_POWEROFF: + case UIC_CMD_DME_ENABLE: + case UIC_CMD_DME_RESET: + case UIC_CMD_DME_END_PT_RST: + case UIC_CMD_DME_LINK_STARTUP: + case UIC_CMD_DME_HIBER_ENTER: + case UIC_CMD_DME_HIBER_EXIT: + case UIC_CMD_DME_TEST_MODE: + ret = -ENOTSUPP; + pr_err("%s unsupported command 0x%x\n", __func__, cmd); + break; + default: + ret = -EINVAL; + } + + if (ret) + pr_err("%s error in command 0x%x\n", __func__, cmd); + + uc->argument3 = mib_val; + + return ret; +} + static int ufs_bsg_request(struct bsg_job *job) { struct ufs_bsg_request *bsg_request = job->request; @@ -68,6 +117,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 = {}; struct utp_upiu_req *req_upiu = NULL; struct utp_upiu_req *rsp_upiu = NULL; int msgcode; @@ -122,7 +172,11 @@ static int ufs_bsg_request(struct bsg_job *job) break; case UPIU_TRANSACTION_UIC_CMD: - /* later */ + memcpy(&uc, &bsg_request->tsf.uc, UIC_CMD_SIZE); + ret = ufs_bsg_exec_uic_cmd(&uc); + memcpy(&bsg_reply->tsf.uc, &uc, UIC_CMD_SIZE); + + break; case UPIU_TRANSACTION_COMMAND: case UPIU_TRANSACTION_DATA_OUT: not_supported: diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs/ufs_bsg.h index 9cc71bc..219597d 100644 --- a/drivers/scsi/ufs/ufs_bsg.h +++ b/drivers/scsi/ufs/ufs_bsg.h @@ -15,6 +15,8 @@ #define UFS_BSG_NOP (-1) #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,