Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3969129pxb; Mon, 8 Feb 2021 05:00:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3P82Tbw158ywtI735UT/fCBHCvtZEo1we6svb3sy+aO3xqtyyPp5AD6Vt1fZp69BcHSUw X-Received: by 2002:a05:6402:1153:: with SMTP id g19mr12351652edw.292.1612789205175; Mon, 08 Feb 2021 05:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612789205; cv=none; d=google.com; s=arc-20160816; b=FQfYtEjK8OTpSbU0SwcHEtLg8gi+jHrn4/FOmnkZLQrH2awdepkheocOxosEDTIJih N1Nf4gM50mw/6HJqK0IP41KfMq3VXCEVjU5BKEUh5uMsbzaKfTDCo121Pjs1yaZPVJ6D 266bWNYjLqKJfkKxm0e3NJf8VoWUDuuGgdqrnJhiLurSXjf982/c+/7GNyseCtJMYjH5 7BAq3c5SRPpV1IBTksDxf7huki78WikM1ct0i+aG/U0+0kBG49kZWHA4p17ml2oU2scN wrXcIESTsx3mn/L/2uTDVjnq8dQVD2QWZjq1IZQHLGupJw+EZ+Jj/wES+5hfJrUdFy4k yBSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=sQapmmmD1H+xp8DLEh2Jo59f71Qc7V57DYbFZYvaoAY=; b=rDft+Wq93rnTyTzJkdKVkMbM/mt73keGgnp0TUxePQZb5/6Xp9uIELuSxr834UomGB uAf0H01WQusghjsx08P0y/k7X/m5i2CQAYcdNrlUb5zfpQ8DPplp93Tl5DESxFcxV7bx WTOlU6JhpyP3JTWmCqJiEPPyE+tvBok9AAhDVAz9MhrYdwXg8XnHs3tNYG3fE0xfyspU bapmBTmOUcx6SECyXw4SSQY4YgxecW0dxSwTP5U6f8vgxSOhdPvwXz1M0jH94JyXDWJi WXslIJd4nLwFt1l9BX1MtOQO3GbR/InnR/rsNqk81hpNvhN58E37+0CLTItyn/8IzWJp icKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OuvN92Sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y29si12261818edi.212.2021.02.08.04.59.40; Mon, 08 Feb 2021 05:00:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OuvN92Sq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhBHM5a (ORCPT + 99 others); Mon, 8 Feb 2021 07:57:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbhBHM53 (ORCPT ); Mon, 8 Feb 2021 07:57:29 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D6EC061788 for ; Mon, 8 Feb 2021 04:56:48 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id l10so17045373ybt.6 for ; Mon, 08 Feb 2021 04:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=sQapmmmD1H+xp8DLEh2Jo59f71Qc7V57DYbFZYvaoAY=; b=OuvN92SqUW+TAnggwqjIb2dlgpxNei1LU6zL/tAyxL48x74UE9j2SP1xkbflB+HLWf 81BI1v95NBcVmy68BqAri1q6pZDbZvLTwmVqUQDOq+RZLugpXZa7Jt+nsfbkTwPkcDpF YyegRzS6Z0GpRq/tVfmFm5vyPdS5yXKsnwyw2YtVHNhOzjSPrpIPSHJVjRpkslvp+J9G +gPe8V4pbQ4N5/nAGBQv6b59NeMstXsYpTr5iVLkrm1Q08tq0AAclcJ2PieVQILiTRrR 6zvYMG5JQFItRPjtC+zdLQk/UbIES8OOKqLy1dZJ16Wb4mnEA361eFXYkvDZD3rDjQ3P GQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=sQapmmmD1H+xp8DLEh2Jo59f71Qc7V57DYbFZYvaoAY=; b=q6FZvZSOYk/qoalh6kVEDbaWz/483rqmBt7Wd/Z+hg3zAx7+xq0UwpsmOgwNtFlW9n YKPRYpJaNShOIoV/kG5AWE8WwzTzjqCkYRc4QPjtIQKJ0mMYuhrZln/OLxSGLySUtHkI /j3vkdtec6D7qRAPPIvKjCdPsaVpdPkGCObHoG12iTxnZR0rbkLYL26Q1zVJkehvhEu2 jCIsdiMbSSdgmN1+w3M/Slj46dlrHFQ1qFo/QdATZGBK6LfEfEJWJIYhzNEwOASGJ1L8 ZZNx/iOAsxZbatsKaFUnH5UJ84DgFlslBhkG2uX/NXECYZqWDZHh3WlQ4WcLFmwhBAO+ Wp2g== X-Gm-Message-State: AOAM531UKEF7g5BPapI4/5BSn/TTgpRt9oA1jXx+ZZPw70xYTqgT26CF POA3hMHkIN4DiFzQjRUprGyq7cbCDl4G Sender: "leoliou via sendgmr" X-Received: from leoliou.ntc.corp.google.com ([2401:fa00:fc:202:9995:e502:106b:c601]) (user=leoliou job=sendgmr) by 2002:a25:264b:: with SMTP id m72mr25645047ybm.486.1612789007205; Mon, 08 Feb 2021 04:56:47 -0800 (PST) Date: Mon, 8 Feb 2021 20:56:28 +0800 Message-Id: <20210208125628.2758665-1-leoliou@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [PATCH] scsi: ufs: create a hook for unipro dme control From: Leo Liou To: agross@kernel.org, bjorn.andersson@linaro.org, alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, cang@codeaurora.org, asutoshd@codeaurora.org, beanhuo@micron.com, jaegeuk@kernel.org, adrian.hunter@intel.com, satyat@google.com, essuuj@gmail.com, linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: leoliou@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on ufshci spec, it defines that "Offset C0h to FFh" belong to vendor specific. If cpu vendor doesn't support these commands, it makes the dme errors: ufs: dme-set: attr-id 0xd041 val 0x1fff failed 0 retries ufs: dme-set: attr-id 0xd042 val 0xffff failed 0 retries ufs: dme-set: attr-id 0xd043 val 0x7fff failed 0 retries Create a hook for unipro vendor-specific commands. Signed-off-by: Leo Liou --- drivers/scsi/ufs/ufs-qcom.c | 11 +++++++++++ drivers/scsi/ufs/ufs-qcom.h | 5 +++++ drivers/scsi/ufs/ufshcd.c | 7 +------ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ drivers/scsi/ufs/unipro.h | 4 ---- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 2206b1e4b774..f2a925587029 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -759,6 +759,16 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba, return ret; } +static void ufs_qcom_unipro_dme_set(struct ufs_hba *hba) +{ + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalFC0ProtectionTimeOutVal), + DL_FC0ProtectionTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalTC0ReplayTimeOutVal), + DL_TC0ReplayTimeOutVal_Default); + ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalAFC0ReqTimeOutVal), + DL_AFC0ReqTimeOutVal_Default); +} + static int ufs_qcom_quirk_host_pa_saveconfigtime(struct ufs_hba *hba) { int err; @@ -1469,6 +1479,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .hce_enable_notify = ufs_qcom_hce_enable_notify, .link_startup_notify = ufs_qcom_link_startup_notify, .pwr_change_notify = ufs_qcom_pwr_change_notify, + .unipro_dme_set = ufs_qcom_unipro_dme_set, .apply_dev_quirks = ufs_qcom_apply_dev_quirks, .suspend = ufs_qcom_suspend, .resume = ufs_qcom_resume, diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index 8208e3a3ef59..83db97caaa1b 100644 --- a/drivers/scsi/ufs/ufs-qcom.h +++ b/drivers/scsi/ufs/ufs-qcom.h @@ -124,6 +124,11 @@ enum { /* QUniPro Vendor specific attributes */ #define PA_VS_CONFIG_REG1 0x9000 #define DME_VS_CORE_CLK_CTRL 0xD002 + +#define DME_LocalFC0ProtectionTimeOutVal 0xD041 +#define DME_LocalTC0ReplayTimeOutVal 0xD042 +#define DME_LocalAFC0ReqTimeOutVal 0xD043 + /* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */ #define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8) #define DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK 0xFF diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index fb32d122f2e3..8ba2ce8c5d0c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4231,12 +4231,7 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA5), DL_AFC1ReqTimeOutVal_Default); - ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalFC0ProtectionTimeOutVal), - DL_FC0ProtectionTimeOutVal_Default); - ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalTC0ReplayTimeOutVal), - DL_TC0ReplayTimeOutVal_Default); - ufshcd_dme_set(hba, UIC_ARG_MIB(DME_LocalAFC0ReqTimeOutVal), - DL_AFC0ReqTimeOutVal_Default); + ufshcd_vops_unipro_dme_set(hba); ret = ufshcd_uic_change_pwr_mode(hba, pwr_mode->pwr_rx << 4 | pwr_mode->pwr_tx); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index aa9ea3552323..b8c90bee7503 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -311,6 +311,7 @@ struct ufs_pwr_mode_info { * @pwr_change_notify: called before and after a power mode change * is carried out to allow vendor spesific capabilities * to be set. + * @unipro_dme_set: called when vendor speicific control is needed * @setup_xfer_req: called before any transfer request is issued * to set some things * @setup_task_mgmt: called before any task management request is issued @@ -342,6 +343,7 @@ struct ufs_hba_variant_ops { enum ufs_notify_change_status status, struct ufs_pa_layer_attr *, struct ufs_pa_layer_attr *); + void (*unipro_dme_set)(struct ufs_hba *hba); void (*setup_xfer_req)(struct ufs_hba *, int, bool); void (*setup_task_mgmt)(struct ufs_hba *, int, u8); void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, @@ -1161,6 +1163,12 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, return -ENOTSUPP; } +static inline void ufshcd_vops_unipro_dme_set(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->unipro_dme_set) + return hba->vops->unipro_dme_set(hba); +} + static inline void ufshcd_vops_setup_xfer_req(struct ufs_hba *hba, int tag, bool is_scsi_cmd) { diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 8e9e486a4f7b..224162e5afd8 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -192,10 +192,6 @@ #define DL_TC1ReplayTimeOutVal_Default 65535 #define DL_AFC1ReqTimeOutVal_Default 32767 -#define DME_LocalFC0ProtectionTimeOutVal 0xD041 -#define DME_LocalTC0ReplayTimeOutVal 0xD042 -#define DME_LocalAFC0ReqTimeOutVal 0xD043 - /* PA power modes */ enum { FAST_MODE = 1, -- 2.30.0.478.g8a0d178c01-goog