From patchwork Tue Nov 8 07:48:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 9416823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 449576022E for ; Tue, 8 Nov 2016 07:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3410128A9E for ; Tue, 8 Nov 2016 07:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2836D28AA8; Tue, 8 Nov 2016 07:59:11 +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=-6.9 required=2.0 tests=BAYES_00,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 9B96228AA2 for ; Tue, 8 Nov 2016 07:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbcKHH7K convert rfc822-to-8bit (ORCPT ); Tue, 8 Nov 2016 02:59:10 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:60955 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752881AbcKHH7J (ORCPT ); Tue, 8 Nov 2016 02:59:09 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGB007APCC3T230@mailout2.samsung.com> for linux-scsi@vger.kernel.org; Tue, 08 Nov 2016 16:48:07 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-2a-582183371df2 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id F6.75.16530.73381285; Tue, 8 Nov 2016 16:48:07 +0900 (KST) Received: from DOKWMADKIM02 ([12.36.166.218]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGB00KC0CC6MR50@mmp2.samsung.com>; Tue, 08 Nov 2016 16:48:07 +0900 (KST) From: Kiwoong Kim To: "James E.J. Bottomley" , linux-scsi@vger.kernel.org, "Martin K. Petersen" , vinholikatti@gmail.com Cc: =?UTF-8?B?7LaU7ZeM6rSR?= Subject: [PATCH v1] ufs: introduce setup_hibern8 callback Date: Tue, 08 Nov 2016 16:48:07 +0900 Message-id: <001f01d23994$719997c0$54ccc740$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT X-Mailer: Microsoft Outlook 15.0 Thread-index: AdI5lGEgdtHKKBbhQeShjyliEBFfpA== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRmVeSWpSXmKPExsVy+t9jQV3zZsUIgyXz+S1mX2hitFg1Mc+i +/oONovlx/8xWexYWOXA6rFz1l12jweHNrN4fHx6i8Wjb8sqRo/Pm+QCWKPcbDJSE1NSixRS 85LzUzLz0m2VQkPcdC2UFPISc1NtlSJ0fUOClBTKEnNKgTwjAzTg4BzgHqykb5fglvHw6V62 grkSFe/6vzM3MN4U7mLk5JAQMJF4tqKZEcIWk7hwbz1bFyMXh5DALEaJiXPOM0M47xklZj5t YwepYhPQlHh6cyoTSEJEYD6jxKIdO1lAEswChhIb7k8GGyUsYCmx9sUkVhCbRUBVYn/nTCYQ mxco3rF4LyOELSjxY/I9qF51iUnzFjFD2NoST95dYIU4SUFi96ejYLaIgJ7E5Omv2SFqRCT2 vXjHOIER6E6EUbOQjJqFZNQsJC0LGFlWMUqkFiQXFCel5xrlpZbrFSfmFpfmpesl5+duYgTH 2TPpHYyHd7kfYhTgYFTi4XW4qxAhxJpYVlyZe4hRgoNZSYSXu1oxQog3JbGyKrUoP76oNCe1 +BCjKdCzE5mlRJPzgSkgryTe0MTcxNzYwMLc0tLESEmct3H2s3AhgfTEktTs1NSC1CKYPiYO TqkGRoGJTlqiShN1HWz2FEvxpVeEzjjcyrGhIkE/Kj+m8/FC5ZX+VieKDmnob9oTzevcYNj+ VanUa+uZgoN92wyevnkq+VMsQPBA1+IDQcqqxjv1trB0C384tPLKH2Xpw8pvZ5hnGIrutzyh /XnLpELRnwyG+R9Px93Ud4tdnia5xMc1gsEo2D9AiaU4I9FQi7moOBEAKjU1fMkCAAA= X-MTR: 20000000000000000@CPGS 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 Some UFS host controller may need to configure some things around hibern8 enter/exit Signed-off-by: Kiwoong Kim --- drivers/scsi/ufs/ufshcd.c | 10 ++++++++-- drivers/scsi/ufs/ufshcd.h | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index fdb0502..d4a5a9c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2697,6 +2697,8 @@ static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba) int ret; struct uic_command uic_cmd = {0}; + ufshcd_vops_setup_hibern8(hba, true, PRE_CHANGE); + uic_cmd.command = UIC_CMD_DME_HIBER_ENTER; ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd); @@ -2710,7 +2712,8 @@ static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba) */ if (ufshcd_link_recovery(hba)) ret = -ENOLINK; - } + } else + ufshcd_vops_setup_hibern8(hba, true, POST_CHANGE); return ret; } @@ -2733,13 +2736,16 @@ static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba) struct uic_command uic_cmd = {0}; int ret; + ufshcd_vops_setup_hibern8(hba, false, PRE_CHANGE); + uic_cmd.command = UIC_CMD_DME_HIBER_EXIT; ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd); if (ret) { dev_err(hba->dev, "%s: hibern8 exit failed. ret = %d\n", __func__, ret); ret = ufshcd_link_recovery(hba); - } + } else + ufshcd_vops_setup_hibern8(hba, false, POST_CHANGE); return ret; } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index b084d89..13504b4 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -265,6 +265,8 @@ struct ufs_pwr_mode_info { * to set some things * @setup_task_mgmt: called before any task management request is issued * to set some things + * @setup_hibern8: called around hibern8 enter/exit + * to configure some things * @suspend: called during host controller PM callback * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information @@ -290,6 +292,7 @@ struct ufs_hba_variant_ops { struct ufs_pa_layer_attr *); void (*setup_xfer_req)(struct ufs_hba *, int, bool); void (*setup_task_mgmt)(struct ufs_hba *, int, u8); + void (*setup_hibern8)(struct ufs_hba *, bool, bool); int (*suspend)(struct ufs_hba *, enum ufs_pm_op); int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); @@ -821,6 +824,13 @@ static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, return hba->vops->setup_task_mgmt(hba, tag, tm_function); } +static inline void ufshcd_vops_setup_hibern8(struct ufs_hba *hba, + bool enter, bool notify) +{ + if (hba->vops && hba->vops->setup_hibern8) + return hba->vops->setup_hibern8(hba, enter, notify); +} + static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op) { if (hba->vops && hba->vops->suspend)