From patchwork Tue Mar 29 10:41:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Winkler, Tomas" X-Patchwork-Id: 8685691 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9E28C0553 for ; Tue, 29 Mar 2016 10:42:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3F1020212 for ; Tue, 29 Mar 2016 10:42:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B44D9201FE for ; Tue, 29 Mar 2016 10:42:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756756AbcC2KmM (ORCPT ); Tue, 29 Mar 2016 06:42:12 -0400 Received: from mga01.intel.com ([192.55.52.88]:60770 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751937AbcC2Kln convert rfc822-to-8bit (ORCPT ); Tue, 29 Mar 2016 06:41:43 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 29 Mar 2016 03:41:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,410,1455004800"; d="scan'208";a="773748025" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 29 Mar 2016 03:41:41 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 29 Mar 2016 03:41:41 -0700 Received: from hasmsx107.ger.corp.intel.com (10.184.198.27) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 29 Mar 2016 03:41:40 -0700 Received: from hasmsx108.ger.corp.intel.com ([169.254.9.222]) by hasmsx107.ger.corp.intel.com ([169.254.6.225]) with mapi id 14.03.0248.002; Tue, 29 Mar 2016 13:41:38 +0300 From: "Winkler, Tomas" To: Joao Pinto , "martin.petersen@oracle.com" CC: "CARLOS.PALMINHA@synopsys.com" , "ijc+devicetree@hellion.org.uk" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "devicetree@vger.kernel.org" , "arnd@arndb.de" , "robh@kernel.org" Subject: RE: [RESEND] [PATCH v11 2/6] added UFS 2.0 capabilities Thread-Topic: [RESEND] [PATCH v11 2/6] added UFS 2.0 capabilities Thread-Index: AQHRhbcl+PWIcmU6eUSEdX4SfFHbC59wP+IQ Date: Tue, 29 Mar 2016 10:41:37 +0000 Message-ID: <5B8DA87D05A7694D9FA63FD143655C1B541CD26F@hasmsx108.ger.corp.intel.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.184.70.11] MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adding UFS 2.0 support to the UFS core driver. Signed-off-by: Joao Pinto Acked-by: Arnd Bergmann Acked-by: Rob Herring --- Changes v8->v11: - Nothing changed (just to keep up with patch set version). Changes v7->v8: - Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings Changes v0->v7: - Nothing changed (just to keep up with patch set version). .../devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 +-- drivers/scsi/ufs/ufshcd.c | 29 +++++++++++++++++++--- drivers/scsi/ufs/ufshci.h | 1 + 3 files changed, 28 insertions(+), 6 deletions(-) -- 1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt index 03c0e98..8d9a9d2 100644 --- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt @@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host controllers. Each UFS controller instance should have its own node. Required properties: -- compatible : must contain "jedec,ufs-1.1", may also list one or more - of the following: +- compatible : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may + also list one or more of the following: "qcom,msm8994-ufshc" "qcom,msm8996-ufshc" "qcom,ufshc" diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 85cd256..2b5f2bf 100644 I think this should go in separate patch --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) ret = -EINVAL; } break; + case UTP_CMD_TYPE_UFS_STORAGE: case UTP_CMD_TYPE_DEV_MANAGE: ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE); if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY) @@ -1287,6 +1288,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) struct ufshcd_lrb *lrbp; struct ufs_hba *hba; unsigned long flags; + u32 upiu_flags; int tag; int err = 0; @@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp->task_tag = tag; lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false; - lrbp->command_type = UTP_CMD_TYPE_SCSI; + + if (hba->ufs_version == UFSHCI_VERSION_20) + lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE; + else + lrbp->command_type = UTP_CMD_TYPE_SCSI; This translation can be pushed to prepare_req_desc_hdr and you end up with ~oneliner fix /* form UPIU before issuing the command */ - ufshcd_compose_upiu(hba, lrbp); + if (hba->ufs_version == UFSHCI_VERSION_20) { + if (likely(lrbp->cmd)) { How this can be possible NULL, the code above will crash or I'm missing something ? + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, + lrbp->cmd->sc_data_direction); + ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags); What is different her from the code in ufshcd_compose_upiu ? + } else + err = -EINVAL; + } else + ufshcd_compose_upiu(hba, lrbp); + err = ufshcd_map_sg(lrbp); if (err) { lrbp->cmd = NULL; @@ -1371,7 +1386,12 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; /* device management cmd is not specific to any LUN */ - lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE; + + if (hba->ufs_version == UFSHCI_VERSION_20) + lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE; + else + lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE; + This translation can be pushed to prepare_req_desc_hdr and you end up with ~ oneliner fix lrbp->intr_cmd = true; /* No interrupt aggregation */ hba->dev_cmd.type = cmd_type; @@ -3187,7 +3207,8 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba) /* Do not touch lrbp after scsi done */ cmd->scsi_done(cmd); __ufshcd_release(hba); - } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) { + } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || + lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { if (hba->dev_cmd.complete) complete(hba->dev_cmd.complete); } diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index 0ae0967..8dba0e7 100644 --- a/drivers/scsi/ufs/ufshci.h +++ b/drivers/scsi/ufs/ufshci.h @@ -273,6 +273,7 @@ enum { UTP_CMD_TYPE_SCSI = 0x0, UTP_CMD_TYPE_UFS = 0x1, UTP_CMD_TYPE_DEV_MANAGE = 0x2, + UTP_CMD_TYPE_UFS_STORAGE = 0x11, }; enum {