From patchwork Sun Sep 30 05:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10621145 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 CCF8D14BD for ; Sun, 30 Sep 2018 05:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF90429AEE for ; Sun, 30 Sep 2018 05:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F37629AF2; Sun, 30 Sep 2018 05:46:16 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1655729AEE for ; Sun, 30 Sep 2018 05:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbeI3MRs (ORCPT ); Sun, 30 Sep 2018 08:17:48 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:13039 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbeI3MRs (ORCPT ); Sun, 30 Sep 2018 08:17:48 -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=1538286374; x=1569822374; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IEZ7w4E/Ejfeb5+W9HKmUhjb8FRl2mweoSQiLTTWkIA=; b=BCmmZ/pgzz5yv5ZmrkwNlBa3fR0xw95KDTxm5cY1VnASdek9CEK3efRy ZZ7erWk6M3qxS2l7NzGukpHU6GECbYZXpttMw+ovC6NhPcM1+JjLjlS5q H/Og1kkbolKz0G/s/U6lQsoUnp17lB7/7Dt6dtrbjHpI8TwbGMnEwe6Y1 5/T5ww8CI71chc9s9L0yCCNjDrX1ccN8hht0fDsGXkIL8KlDwj7cW6hyL lTPyFGvlJO3HX4UV9HfdtoezmeMAKuXlJGsUH/eG2CcF6p9Pif7lofwmK 76smuUiShp73bNoTnIE6tASSl1oR3EmLDhKvuL31TQ2Hfzmx0rORcojoH g==; X-IronPort-AV: E=Sophos;i="5.54,322,1534780800"; d="scan'208";a="90893722" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 Sep 2018 13:46:14 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 29 Sep 2018 22:31:55 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Sep 2018 22:46:11 -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 v7 0/8] scsi: Add ufs bsg endpoint Date: Sun, 30 Sep 2018 08:45:52 +0300 Message-Id: <1538286360-7319-1-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 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 Here is a proposal to use a bsg endpoint to manage ufs devices. We will do that by adding a bsg device node to the ufs driver, and use it to send UPIU transactions to the ufs device. It will serve as a ufs device management infrastructure, for device configuration, provisioning, testing and validation, etc. We added a new ufs-bsg module, and some new API to the ufs driver. For the time being, we will not use it for data transfer, but just for device management per-se. This has nothing to do with the recent removal of bsg read/write support, we might add this capability in the future, but it is not our current focus. We tested it on a Hikey-960 platform with a V4.14 kernel, "modernized" by recent bsg and ufs patches. We also used a htc11 with a V4.4 kernel, but needed much more transport/bsg/ufs patches to make it relevant. Many thanks to Christoph and Bart for their much appreciated support and comments. V6->v7: Split out a new prep patch that creates include/uapi/scsi/scsi_bsg_ufs.h. Check for a desc_op instead of passing the magic UFS_BSG_NOP in ufshcd_exec_raw_upiu_cmd. Add Reviewed-by tags. V5->v6: Remove the host and device indices from the bsg device name, as there can be only one. Use the structure size in pointer arithmetic's instead of an opaque 32 bytes for the over allocation of descriptors. Move ufs_bsg_request and ufs_bsg_reply to include/uapi/scsi/scsi_bsg_ufs.h. Withdraw from decoding uic command, and just use ufshcd_send_uic_cmd Instead. V4->v5: use the new lower-level __ufshcd_issue_tm_cmd directly, so "Allow ufshcd_issue_tm_cmd accept raw upiu" is not needed any more. Get rid of struct ufs_bsg_node which simplifies ufs_bsg_probe(). Also some small adjustments to v4 fixes. Have only one length and format for the reply. Add a documentation of the API as a paragraph in Documentation/scsi/ufs.txt. V3->v4: Squashed the bsg node Instantiation into "Add ufs-bsg". Build ufs-bsg as part of ufshcd-core and not as a separate module. Also merged the ufs_bsg_node into the ufs_hba structure. Christoph refactored the task management code, cleaning it up and making it much more readable - attached as the first 2 patches In the series. Afterward passing an external upiu to ufshcd_issue_tm_cmd Just blends in. V2->v3: We dropped the scsi transport code (and changed this patch title to account for it) as we actually just need the bsg device node. We also withdraw (brokenhearted) from our intension to create several bsg devices, and add just one. Rephrased the doc in Kconfig. V1->v2: Use inline functions instead of defines, and ida to obtain the port indices, in scsi_transport_ufs module. Remove the closing data pointer and __packed notation from struct ufs_bsg_{request_reply}. Re-use ufshcd_issue_tm_cmd code - needed a couple of patches for that, and call req_upiu and rsp_upio with their appropriate struct pointers. Use a more appropriate name when checking if enough memory was allocated for write descriptor, and remove redundant goto. Add reference to the spec to explain uic command size. Fix a lot of typos. Avri Altman (6): uapi: ufs: Make utp_upiu_req visible to user space scsi: ufs: Add ufs-bsg module scsi: ufs: Use data structure size in pointer arithmetic scsi: ufs: Add API to execute raw upiu commands scsi: ufs-bsg: Add support for raw upiu in ufs_bsg_request() scsi: ufs-bsg: Add support for uic commands in ufs_bsg_request() Christoph Hellwig (2): scsi: ufs: cleanup struct utp_task_req_desc scsi: ufs: add a low-level __ufshcd_issue_tm_cmd helper Documentation/scsi/ufs.txt | 20 +++ drivers/scsi/ufs/Kconfig | 19 ++ drivers/scsi/ufs/Makefile | 3 +- drivers/scsi/ufs/ufs.h | 94 +--------- drivers/scsi/ufs/ufs_bsg.c | 210 ++++++++++++++++++++++ drivers/scsi/ufs/ufs_bsg.h | 23 +++ drivers/scsi/ufs/ufshcd.c | 367 ++++++++++++++++++++++++++------------- drivers/scsi/ufs/ufshcd.h | 12 ++ drivers/scsi/ufs/ufshci.h | 25 +-- include/uapi/scsi/scsi_bsg_ufs.h | 105 +++++++++++ 10 files changed, 657 insertions(+), 221 deletions(-) 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