From patchwork Fri Sep 7 09:49:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 10591969 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 787F46CB for ; Fri, 7 Sep 2018 09:51:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57E872AD61 for ; Fri, 7 Sep 2018 09:51:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BC492AD72; Fri, 7 Sep 2018 09:51:07 +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 C85652AD61 for ; Fri, 7 Sep 2018 09:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728296AbeIGObP (ORCPT ); Fri, 7 Sep 2018 10:31:15 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:52672 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbeIGObP (ORCPT ); Fri, 7 Sep 2018 10:31:15 -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=1536313866; x=1567849866; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=R1wqg9yl9wHO57SV9dMDxZdUuiZWNNXLpVd3obHN068=; b=UgAzgrNBSxr+rxySXfml3m9kGTcd298zJQo6yl7/OhylKtmhMGaPctTB IBrrCkiPs7ULdEjZTjpZEgnbTO/3fPtrROInwGlruXk7fobY+LAA4iD/N Iix2FSnn/BHKET/Sa1sQY+DV578/Y90OHn4ZDsoVGZVXPZiK1HuAz0HCN dLDf50HrcaPkxjEvNiHuBwcFVl7amIibmUNad+t09eu/zfw2CsD0ke7no ZEYmm0c1Hm3Zm8zxoHjmitzacvAJ2KYOuaWlbedpdUD9wfOteh9htQ7US tyN25XBYwRTSAjoYYxcm03lnwe5RNyMitJBRuCcxOFgTB+rrzQk3KyVop g==; X-IronPort-AV: E=Sophos;i="5.53,341,1531756800"; d="scan'208";a="89268009" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Sep 2018 17:51:06 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 07 Sep 2018 02:37:36 -0700 Received: from kfae422988.sdcorp.global.sandisk.com ([10.0.231.37]) by uls-op-cesaip01.wdc.com with ESMTP; 07 Sep 2018 02:51:03 -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 v4 3/7] scsi: ufs: Allow ufshcd_issue_tm_cmd accept raw upiu Date: Fri, 7 Sep 2018 12:49:39 +0300 Message-Id: <1536313783-13025-4-git-send-email-avri.altman@wdc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1536313783-13025-1-git-send-email-avri.altman@wdc.com> References: <1536313783-13025-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 | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c7809fa..d021c3a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5610,12 +5610,20 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, * * 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_req *req_upiu, + struct utp_upiu_req *rsp_upiu, + int lun_id, int task_id, + u8 tm_function, u8 *tm_response) { struct utp_task_req_desc treq = { { 0 }, }; int ocs_value, err; + if (req_upiu) { + memcpy(&treq.req_header, req_upiu, GENERAL_UPIU_REQUEST_SIZE); + goto issue_tm_cmd; + } + /* Configure task request descriptor */ treq.header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD); treq.header.dword_2 = cpu_to_le32(OCS_INVALID_COMMAND_STATUS); @@ -5632,17 +5640,24 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, treq.input_param1 = cpu_to_be32(lun_id); treq.input_param2 = cpu_to_be32(task_id); +issue_tm_cmd: err = __ufshcd_issue_tm_cmd(hba, &treq, tm_function); if (err == -ETIMEDOUT) return err; ocs_value = le32_to_cpu(treq.header.dword_2) & MASK_OCS; - if (ocs_value != OCS_SUCCESS) + if (ocs_value != OCS_SUCCESS) { dev_err(hba->dev, "%s: failed, ocs = 0x%x\n", __func__, ocs_value); - else if (tm_response) - *tm_response = be32_to_cpu(treq.output_param1) & - MASK_TM_SERVICE_RESP; + } else { + if (tm_response) + *tm_response = be32_to_cpu(treq.output_param1) & + MASK_TM_SERVICE_RESP; + if (rsp_upiu) + memcpy(rsp_upiu, &treq.rsp_header, + GENERAL_UPIU_REQUEST_SIZE); + + } return err; } @@ -5669,7 +5684,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; @@ -5799,8 +5815,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", @@ -5838,8 +5855,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 */