Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp538297pxb; Tue, 3 Nov 2020 06:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbpinwLmXBhWjSTJjs5famRxnEJQCWeC0L81eN2Tdorx4vdNlVOBI+2ZfoaCSYS6uDjiNr X-Received: by 2002:a17:906:6702:: with SMTP id a2mr19729433ejp.309.1604412991165; Tue, 03 Nov 2020 06:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604412991; cv=none; d=google.com; s=arc-20160816; b=HJSSWe5D3QIBLm5W/vpTIHiHcWeZUqA4KE2ce/IauAy6onAHhUvpkNQ2r0lR8oD8nP OKoSJXU02MbN2gWW3xixwcFSb6DVx2ssfAYU2Fb3MHyZzuZ8x6TEFze+dsUwzybppqst uNCKh+2sIhh+djeaaNDF7YtpXnVyuFtCwAYxHBsBprJuJ1xlRMRDj64kDBbXKfYQj0MC GK5+WVxKdEJReUyBaGxy95aPDkwYSAm0y8bV8kYtnJYFN6Kv1oMRGD8ZAgtQoW8MqiGQ 7IVdqHzoVg3SMIL3yse1Xn8EZHdAyupcQ0KMtQ2XR/z2/sjRtkMy75oRIoblS3r3Yj85 JELg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:references:in-reply-to:message-id :date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=h65ICLG1T7cD0xV8MmdxLnEgN9+wxHXji6vHBT4YeKI=; b=gfmD0/EKp/zb8LzjDGxUdsxCI76jPugrqpxkBfVOgS89LPZUfy/Q3er+vbyBuKQUOX ptA7SHGUlD0v4+PCIH/O2DXbz1Q+tRHkT0xUgwad6xYuARZVWACtWTZ3WVJ3rJOMMym+ zseyoCoIyoNL8OpxgoIt4bh1vL2/UHJKsq2OD+ISziBaz3EtMsnsmWIN5oJsnY5kESA6 8TiqFEuk70vPfRcJQ6J7+OZuKec2+FsSZEBgPe7CkOaMOINg87+Zp8XJEPqtdI62PY77 TDUF6z2+KnrL8l+5GK4Gq5ankz3xLS7KvKRE2N8kbxe9I0+ikrThoeWN6k0VAC5XN8hF Ofmw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si2518573ejk.655.2020.11.03.06.16.07; Tue, 03 Nov 2020 06:16:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729492AbgKCOOu (ORCPT + 99 others); Tue, 3 Nov 2020 09:14:50 -0500 Received: from mga02.intel.com ([134.134.136.20]:29139 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729345AbgKCOOY (ORCPT ); Tue, 3 Nov 2020 09:14:24 -0500 IronPort-SDR: 1JRLATAODLYWrr6JdX6NEHvlfzd4KTYKNNrb88ty6+L0g8KqcSRe40/P2ArT6VoZ7MEUXiN6Lj csOvbrpjkvgg== X-IronPort-AV: E=McAfee;i="6000,8403,9793"; a="156045785" X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="156045785" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 06:14:24 -0800 IronPort-SDR: MWk003GDfdTz884kOADsSp0AjGgt8Xs5/xFrA24iyafcih5SJK3AhNqwVFkUq6q0BKRMqBh9pT j7aHJG8enxSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="527170246" Received: from ahunter-desktop.fi.intel.com ([10.237.72.94]) by fmsmga006.fm.intel.com with ESMTP; 03 Nov 2020 06:14:21 -0800 From: Adrian Hunter To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alim Akhtar , Avri Altman , Bean Huo , Can Guo , Stanley Chu Subject: [PATCH V4 2/2] scsi: ufs: Allow an error return value from ->device_reset() Date: Tue, 3 Nov 2020 16:14:03 +0200 Message-Id: <20201103141403.2142-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201103141403.2142-1-adrian.hunter@intel.com> References: <20201103141403.2142-1-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); } } -- 2.17.1