Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1124386pxb; Wed, 4 Nov 2020 00:09:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3d2xY/vhRdDGrhu0CzATr8bfxrLHeNeCiYvz99H1TA0uQulNgy0cGYhuXBeCLpixXXHw4 X-Received: by 2002:a17:907:262d:: with SMTP id aq13mr6597328ejc.484.1604477380480; Wed, 04 Nov 2020 00:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604477380; cv=none; d=google.com; s=arc-20160816; b=PkVrCffMUstUI9II6uu63e34Ftw7QI3/M/uPdlCSNvsct1DmVrs3wT3NQYnFiTIRLf 0lIEM7XOCgdpWB/kNbkqb21TGiCtqk8HLam7wX8kDyW+UyKJUnhL1dpdN6M6ockBk7d+ 2llRsQKIczhzLX0YsgXAX/Sra15koxXHIeswXtY5739c67O8FG/IhoCc6Kv1JjU21UOu EuBTW3F8DvsyJuPnu6gdq2QfVVW/hdQOdBJAUrjsdvUWEf7doDoE0PoI02Ed8lEZdR9P yeFLb0jlYSiZ9lg/SN8KIvUY3EBmkcvHAC+IICgbRFLS/gLQMhb3lCIds5AApvx8LLRS R+bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=wxfvwASrB/f3/DWt6ENzSLU3t+7wgE52tZwlT7h02PU=; b=FaqisZFH9CKOeiuCvCRxxZvz62nBqGshJaMCqOrgHIXWI3ZkpfrZqumm9A65wSSedZ czdMp4s7WJj+M+M6kJ03ojBeU+wqGZXdQsn226+FOWnA7sKf7+jCs9vCjXBfrnrbYKuP 3Psdmgv8EvkgpJwmsaE40umLPfdSyCK3xIzgO+MmEtscHWCvPpnicQVmmYImgM9qGZ6P v3q8LElUQcKGKyO2AeX2aHqM91LdycV2jEbW5Fzp6Vuf658fafyierXn0lhqHwm9CQpW rmtqF5TcoCGQx/wbAT8kKKAQyXRoyq6oMm8mxwNXajDyY9t5rsjWGkPjp/NLUQA4jU45 MQBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="Ef+JSue/"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si788324edu.101.2020.11.04.00.09.17; Wed, 04 Nov 2020 00:09:40 -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=@mg.codeaurora.org header.s=smtp header.b="Ef+JSue/"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728476AbgKDIFt (ORCPT + 99 others); Wed, 4 Nov 2020 03:05:49 -0500 Received: from z5.mailgun.us ([104.130.96.5]:53693 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728465AbgKDIFt (ORCPT ); Wed, 4 Nov 2020 03:05:49 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1604477148; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=wxfvwASrB/f3/DWt6ENzSLU3t+7wgE52tZwlT7h02PU=; b=Ef+JSue/tgn/9t2QGXcD14+2U8eIYLz/eYtMwWaZna2Lznha3KqnpZykrpPt0zh56IDwmj7H g68/bZD36lDx/IanXae09OBLOyK7iptGeFXG+l2s2HsIZ5ZIIZ3F8LslLt3Q6tqyXBr8Yzfs X5J38Rsion9se+p2UAlAih1kJvo= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 5fa260c341e7c4fae7ef0a6e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 04 Nov 2020 08:05:23 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5E2F2C433FF; Wed, 4 Nov 2020 08:05:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 469C8C433C8; Wed, 4 Nov 2020 08:05:21 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Nov 2020 16:05:21 +0800 From: Can Guo To: Adrian Hunter Cc: "Martin K . Petersen" , "James E . J . Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alim Akhtar , Avri Altman , Bean Huo , Stanley Chu Subject: Re: [PATCH V4 2/2] scsi: ufs: Allow an error return value from ->device_reset() In-Reply-To: <20201103141403.2142-3-adrian.hunter@intel.com> References: <20201103141403.2142-1-adrian.hunter@intel.com> <20201103141403.2142-3-adrian.hunter@intel.com> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-03 22:14, Adrian Hunter wrote: > It is simpler for drivers to provide a ->device_reset() callback > irrespective of whether the GPIO, or firmware interface necessary to do > the > reset, is discovered during probe. > > Change ->device_reset() to return an error code. Drivers that provide > the callback, but do not do the reset operation should return > -EOPNOTSUPP. > > Signed-off-by: Adrian Hunter Reviewed-by: Can Guo > --- > drivers/scsi/ufs/ufs-mediatek.c | 4 +++- > drivers/scsi/ufs/ufs-qcom.c | 6 ++++-- > drivers/scsi/ufs/ufshcd.h | 11 +++++++---- > 3 files changed, 14 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/ufs/ufs-mediatek.c > b/drivers/scsi/ufs/ufs-mediatek.c > index 8df73bc2f8cb..914a827a93ee 100644 > --- a/drivers/scsi/ufs/ufs-mediatek.c > +++ b/drivers/scsi/ufs/ufs-mediatek.c > @@ -743,7 +743,7 @@ static int ufs_mtk_link_startup_notify(struct > ufs_hba *hba, > return ret; > } > > -static void ufs_mtk_device_reset(struct ufs_hba *hba) > +static int ufs_mtk_device_reset(struct ufs_hba *hba) > { > struct arm_smccc_res res; > > @@ -764,6 +764,8 @@ static void ufs_mtk_device_reset(struct ufs_hba > *hba) > usleep_range(10000, 15000); > > dev_info(hba->dev, "device reset done\n"); > + > + return 0; > } > > static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) > diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c > index 9a19c6d15d3b..357c3b49321d 100644 > --- a/drivers/scsi/ufs/ufs-qcom.c > +++ b/drivers/scsi/ufs/ufs-qcom.c > @@ -1422,13 +1422,13 @@ static void ufs_qcom_dump_dbg_regs(struct > ufs_hba *hba) > * > * Toggles the (optional) reset line to reset the attached device. > */ > -static void ufs_qcom_device_reset(struct ufs_hba *hba) > +static int ufs_qcom_device_reset(struct ufs_hba *hba) > { > struct ufs_qcom_host *host = ufshcd_get_variant(hba); > > /* reset gpio is optional */ > if (!host->device_reset) > - return; > + return -EOPNOTSUPP; > > /* > * The UFS device shall detect reset pulses of 1us, sleep for 10us to > @@ -1439,6 +1439,8 @@ static void ufs_qcom_device_reset(struct ufs_hba > *hba) > > gpiod_set_value_cansleep(host->device_reset, 0); > usleep_range(10, 15); > + > + return 0; > } > > #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 213be0667b59..5191d87f6263 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -323,7 +323,7 @@ struct ufs_hba_variant_ops { > int (*resume)(struct ufs_hba *, enum ufs_pm_op); > void (*dbg_register_dump)(struct ufs_hba *hba); > int (*phy_initialization)(struct ufs_hba *); > - void (*device_reset)(struct ufs_hba *hba); > + int (*device_reset)(struct ufs_hba *hba); > void (*config_scaling_param)(struct ufs_hba *hba, > struct devfreq_dev_profile *profile, > void *data); > @@ -1207,9 +1207,12 @@ static inline void > ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) > static inline void ufshcd_vops_device_reset(struct ufs_hba *hba) > { > if (hba->vops && hba->vops->device_reset) { > - hba->vops->device_reset(hba); > - ufshcd_set_ufs_dev_active(hba); > - ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, 0); > + int err = hba->vops->device_reset(hba); > + > + if (!err) > + ufshcd_set_ufs_dev_active(hba); > + if (err != -EOPNOTSUPP) > + ufshcd_update_reg_hist(&hba->ufs_stats.dev_reset, err); > } > }