Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2524878imm; Wed, 16 May 2018 14:28:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpCL+MrOFkw0Hrt43zk/U/b2P50WNB9tkiM21UVDV3IpafjMBdhI4x6boRJUbhf7GyWmteA X-Received: by 2002:a62:6c87:: with SMTP id h129-v6mr2544449pfc.179.1526506087905; Wed, 16 May 2018 14:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526506087; cv=none; d=google.com; s=arc-20160816; b=iIGAzRYiBjBi7a8TQyvnhY99myR42U2ThUuI8sWlIVry8onrmxsTDpkVcaS8szxFho /kAajwYhG9vrdmgqjdowa1G6XVwGR1DctKK4Hk5ZnPrJZFKLssYWMm8LJO78UTUzbvVU lL15bO41MUtIJb+BCoB/utroZXSqxTzVLcTMORH2Eh110UR8jRbqRqtdQzt9kokpog9c W4ox6o1qRulgNh/1RM+qxtlmmFB2ZqmcVtWtDUKRwJXJZ4LhBi0BfWbzc6KT0URlM/QW SuClP6tIA1tHVYz1snwVBBoYDjG/2nPAbj28CxW//1B1+K8HbuSARo3oPJrKWJ32f75N apYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=43abfhDB49KozMtcSgsGgconyqX3X+1W26CZY15usYA=; b=a7ytYjOW9KouT0zm6Lzxm+Pz7Ugq66BU84hkjA+YCVPjGSIA3Cr6HbwapD2YMEvHjd afOuVTpPngklM75Dyq/O8WgsysMuEJF7dyJmFUOZjPR1u0AIIYsPkKhMEitkT04+15s/ IfFv0W9Vo3o3SVBJfY8jnb4Q/TxgMFYmS7W6SsDE3ZBmjlbg9jaq1DVnnYW8XMOuidd6 w4CqsPMzgwAuiTB31UCUM3ZvSYAYs3AWcGmmIFBaHyhWSDVZtf9QVlZSoMVrKH7ARI5u iQVLu7z94JEQ4EGdCWGstzp73Qzlk+sVxfwxvAJAYA06CrMC2i8O1RkiJODvz8yOfHrR UplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=CUjh1/xw; dkim=pass header.i=@codeaurora.org header.s=default header.b=aOIAL+ty; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6-v6si3606346pfk.342.2018.05.16.14.27.53; Wed, 16 May 2018 14:28:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=CUjh1/xw; dkim=pass header.i=@codeaurora.org header.s=default header.b=aOIAL+ty; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751319AbeEPV01 (ORCPT + 99 others); Wed, 16 May 2018 17:26:27 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36880 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbeEPV00 (ORCPT ); Wed, 16 May 2018 17:26:26 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BD68160B23; Wed, 16 May 2018 21:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505985; bh=oMVMwrXjwqAWzHt413YaA5m/juaRXt0oGQR8ozI+cgk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CUjh1/xwydMKAVEozf+dTrXSCkndWbdt+WnWLSZ9rmN18QuinYnIP3RmEzgNRH47X 0PbV5JG9A6mssaXJScZ4WYYlW1t+pqmamCtXgLGBUIbXQxHy0qB6GWaFymYpcvfzuF JPS5mFKAKTIJxtH5OoqPN3rnGqvGo1xGSeHIv3Bs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id D4EEF602BA; Wed, 16 May 2018 21:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526505984; bh=oMVMwrXjwqAWzHt413YaA5m/juaRXt0oGQR8ozI+cgk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aOIAL+tyjYxpQjY9HG/H+qRIqWDdxIkdoBchbYxV2C67/x2XJf5nIbLRdkGIjPfqd EvKl1qryYWAi/sBNAKKp2KEeW6FbdRBnYlcYrKFn9ovgMohs5FVS9pWIaryEHYt86g QGm2M/WtW5cjNX/WI1zcBzeO/c/PpUv0JipQS/r4= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 16 May 2018 14:26:24 -0700 From: Subhash Jadavani To: Alim Akhtar Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, vivek.gautam@codeaurora.org, vinholikatti@gmail.com, olof@lixom.net Subject: Re: [PATCH 3/4] scsi: ufs: add quirk to enable host controller without hce In-Reply-To: <1525601658-31989-4-git-send-email-alim.akhtar@samsung.com> References: <1525601658-31989-1-git-send-email-alim.akhtar@samsung.com> <1525601658-31989-4-git-send-email-alim.akhtar@samsung.com> Message-ID: <5466c5674239490053d349a2ab145f72@codeaurora.org> X-Sender: subhashj@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-06 03:14, Alim Akhtar wrote: > Some host controller doesn't support host controller enable via HCE. > > Signed-off-by: Seungwon Jeon > Signed-off-by: Alim Akhtar > --- > drivers/scsi/ufs/ufshcd.c | 75 > +++++++++++++++++++++++++++++++++++++++++++++-- > drivers/scsi/ufs/ufshcd.h | 5 ++++ > 2 files changed, 78 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 253257c..5bfd385 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -3400,6 +3400,52 @@ static int ufshcd_dme_link_startup(struct > ufs_hba *hba) > "dme-link-startup: error code %d\n", ret); > return ret; > } > +/** > + * ufshcd_dme_reset - UIC command for DME_RESET > + * @hba: per adapter instance > + * > + * DME_RESET command is issued in order to reset UniPro stack. > + * This function now deal with cold reset. > + * > + * Returns 0 on success, non-zero value on failure > + */ > +static int ufshcd_dme_reset(struct ufs_hba *hba) > +{ > + struct uic_command uic_cmd = {0}; > + int ret; > + > + uic_cmd.command = UIC_CMD_DME_RESET; > + > + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); > + if (ret) > + dev_err(hba->dev, > + "dme-reset: error code %d\n", ret); > + > + return ret; > +} > + > +/** > + * ufshcd_dme_enable - UIC command for DME_ENABLE > + * @hba: per adapter instance > + * > + * DME_ENABLE command is issued in order to enable UniPro stack. > + * > + * Returns 0 on success, non-zero value on failure > + */ > +static int ufshcd_dme_enable(struct ufs_hba *hba) > +{ > + struct uic_command uic_cmd = {0}; > + int ret; > + > + uic_cmd.command = UIC_CMD_DME_ENABLE; > + > + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); > + if (ret) > + dev_err(hba->dev, > + "dme-reset: error code %d\n", ret); > + > + return ret; > +} > > static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba > *hba) > { > @@ -4058,7 +4104,7 @@ static inline void ufshcd_hba_stop(struct > ufs_hba *hba, bool can_sleep) > } > > /** > - * ufshcd_hba_enable - initialize the controller > + * ufshcd_hba_execute_hce - initialize the controller > * @hba: per adapter instance > * > * The controller resets itself and controller firmware initialization > @@ -4067,7 +4113,7 @@ static inline void ufshcd_hba_stop(struct > ufs_hba *hba, bool can_sleep) > * > * Returns 0 on success, non-zero value on failure > */ > -static int ufshcd_hba_enable(struct ufs_hba *hba) > +static int ufshcd_hba_execute_hce(struct ufs_hba *hba) > { > int retry; > > @@ -4122,6 +4168,31 @@ static int ufshcd_hba_enable(struct ufs_hba > *hba) > return 0; > } > > +static int ufshcd_hba_enable(struct ufs_hba *hba) > +{ > + int ret; > + > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) { > + ufshcd_set_link_off(hba); > + ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE); > + > + /* enable UIC related interrupts */ > + ufshcd_enable_intr(hba, UFSHCD_UIC_MASK); > + ret = ufshcd_dme_reset(hba); > + if (!ret) { > + ret = ufshcd_dme_enable(hba); > + if (!ret) > + ufshcd_vops_hce_enable_notify(hba, POST_CHANGE); > + if (ret) > + dev_err(hba->dev, > + "Host controller enable failed with non-hce\n"); > + } > + } else { > + ret = ufshcd_hba_execute_hce(hba); > + } > + > + return ret; > +} > static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) > { > int tx_lanes, i, err = 0; > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 5c91ff1..013a07e 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -606,6 +606,11 @@ struct ufs_hba { > */ > #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR 0x200 > > + /* > + * This quirks needs to be enabled if host controller cannot be > + * enabled via HCE register. > + */ > + #define UFSHCI_QUIRK_BROKEN_HCE 0x400 > unsigned int quirks; /* Deviations from standard UFSHCI spec. */ > > /* Device deviations from standard UFS device spec. */ Looks good to me. Reviewed-by: Subhash Jadavani -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project