From patchwork Sun Aug 5 11:39:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10556113 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 924A914E2 for ; Sun, 5 Aug 2018 11:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72BD32991C for ; Sun, 5 Aug 2018 11:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62DC029924; Sun, 5 Aug 2018 11:40: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.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 BF6422991C for ; Sun, 5 Aug 2018 11:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726130AbeHENoc (ORCPT ); Sun, 5 Aug 2018 09:44:32 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54174 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbeHENob (ORCPT ); Sun, 5 Aug 2018 09:44:31 -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=1533469215; x=1565005215; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GY9yZ62hWejXo7seNnyj2NK7pXvY3kMhBiRAzFRk+8U=; b=hfsSl8y9u/Q9v3YlhBjtHu1wupHHbglGWX3LomUMrOuNmHW0xLXG/BJ2 8CO3nYE0JnJWEAcA0+7N4lQwmDGGVbIuVBGixjgZXW5Xyr7Vv7WWaxlRU 9FUiX/IlJ3I2iqZA91P6QT2sLq9FdBxrJtNL/ZllmXvvOcNWcPzre9Wgr 31OPyFgYABoglhMjgmNMlEBw18dTBFS+V5VSoioWjrIjNLC1cjpKWJRDV /+Oe/T76ZSrANcH+g6UM25S2hVMLH0QfxCmV4zSIRI3PR57TGMuhbrZXc uDPRwistJO7aC5+fBdoAt0MKD3BOC2RWgTXkYvyA++9B1/+KlfbvJjD8n A==; X-IronPort-AV: E=Sophos;i="5.51,447,1526313600"; d="scan'208";a="88071548" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 05 Aug 2018 19:40:15 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 05 Aug 2018 04:28:32 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip02.wdc.com with ESMTP; 05 Aug 2018 04:40: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 v2 0/8] scsi: scsi transport for ufs devices Date: Sun, 5 Aug 2018 14:39:48 +0300 Message-Id: <1533469196-300-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 the scsi transport subsystem to manage ufs devices. scsi transport is a framework that allow to send scsi commands to a non-scsi devices. Still, it is flexible enough to allow sending non-scsi commands as well. We will use this framework to manage ufs devices by sending UPIU transactions. We added a new scsi transport module, a ufs-bsg LLD companion, 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. We are planning to add this capability in the future. 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. 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 another patch 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 (8): scsi: Add ufs transport class scsi: ufs: Add ufs-bsg module scsi: ufs: Instantiate a ufs transport if its available scsi: ufs: Add fill task management request scsi: ufs: Allow ufshcd_issue_tm_cmd accept raw task upius 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() drivers/scsi/Kconfig | 13 ++ drivers/scsi/Makefile | 1 + drivers/scsi/scsi_transport_ufs.c | 354 ++++++++++++++++++++++++++++++++++++++ drivers/scsi/ufs/Makefile | 1 + drivers/scsi/ufs/ufs_bsg.c | 291 +++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufs_bsg.h | 75 ++++++++ drivers/scsi/ufs/ufshcd.c | 242 +++++++++++++++++++++++--- drivers/scsi/ufs/ufshcd.h | 6 + include/scsi/scsi_transport_ufs.h | 44 +++++ include/uapi/scsi/scsi_bsg_ufs.h | 56 ++++++ 10 files changed, 1055 insertions(+), 28 deletions(-) create mode 100644 drivers/scsi/scsi_transport_ufs.c create mode 100644 drivers/scsi/ufs/ufs_bsg.c create mode 100644 drivers/scsi/ufs/ufs_bsg.h create mode 100644 include/scsi/scsi_transport_ufs.h create mode 100644 include/uapi/scsi/scsi_bsg_ufs.h