From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ABC92C2FB2; Tue, 29 Apr 2025 23:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745970772; cv=none; b=e5mRYekUUNAA4g/VJHsohWM4qZk1C8CsffcNzSBB5rtWRW3K6S77DsPM1583hqGwIjerZUqraju4JRDGQhMoermNWznGKvMR+yBuAkUJQe4qwhymiI/QrNuiSHsf+F/xy2lrycaNSmzwiXZqTmR8HckIRS3oON1HuOzF7a6gJhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745970772; c=relaxed/simple; bh=HQSfel0zXsrAtbuOgsgn0S+PwEYVBh3Kbw7CJYYZaUc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Aqm7Vg7DHTn61m+N8Z3knYrwZt5C0cWtnDGwZ+B+c4a36frXM6TlmcWVZ8uG+kbOGnMrwwRTni6NCbNfO3AOpqqCtkJJvZjUwXYr36F+Joma3E0WJAHqjw4xwEIuSHG5D0K0jcb9boxK4wgxLpQOq6MVMmgcPVsSVQXpLi0DKp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cmw0Za6Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cmw0Za6Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BF92C4CEE3; Tue, 29 Apr 2025 23:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745970772; bh=HQSfel0zXsrAtbuOgsgn0S+PwEYVBh3Kbw7CJYYZaUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmw0Za6QpcsfA/MNU7jLxJIlRMHgCTuWnjCWEzunJ2EBI/PdzLaeUN/Xeqmu2L4xu fOmisH7BvDgHORf5/q09uVkEArzjMvcdKPSTsIsB6+V57ENGxuaECgI7BWKvohvAHW MJxgLF29TIzdDjlghI8/MLRyCDwICXFLGUBP96g5YlLTKnS8wGDZ040nNXbAV9Otfh Y4H0+NScanhdwbon/zQO0jy2Scsa2SB6dEC3aec5Hhhaz/wVcin+wEMQ+r15ccdig1 BQLVXEbS/oBLN+6nkVAnTqGOwl943nz50mc7MfXo8S9fCMUwRvHNEFDbb7r/WipoC6 5vAS3KlZLUPpA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manish Pandey , Bean Huo , Manivannan Sadhasivam , "Martin K . Petersen" , Sasha Levin , James.Bottomley@HansenPartnership.com, bvanassche@acm.org, peter.wang@mediatek.com, avri.altman@wdc.com, quic_nguyenb@quicinc.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 08/21] scsi: ufs: Introduce quirk to extend PA_HIBERN8TIME for UFS devices Date: Tue, 29 Apr 2025 19:52:20 -0400 Message-Id: <20250429235233.537828-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250429235233.537828-1-sashal@kernel.org> References: <20250429235233.537828-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.88 Content-Transfer-Encoding: 8bit From: Manish Pandey [ Upstream commit 569330a34a31a52c904239439984a59972c11d28 ] Samsung UFS devices require additional time in hibern8 mode before exiting, beyond the negotiated handshaking phase between the host and device. Introduce a quirk to increase the PA_HIBERN8TIME parameter by 100 µs, a value derived from experiments, to ensure a proper hibernation process. Signed-off-by: Manish Pandey Link: https://lore.kernel.org/r/20250411121630.21330-3-quic_mapa@quicinc.com Reviewed-by: Bean Huo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/ufs/core/ufshcd.c | 29 +++++++++++++++++++++++++++++ include/ufs/ufs_quirks.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index cb5611cbf4547..2346a1fc72b56 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -257,6 +257,7 @@ static const struct ufs_dev_quirk ufs_fixups[] = { .model = UFS_ANY_MODEL, .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE | + UFS_DEVICE_QUIRK_PA_HIBER8TIME | UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS }, { .wmanufacturerid = UFS_VENDOR_SKHYNIX, .model = UFS_ANY_MODEL, @@ -8459,6 +8460,31 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba) return ret; } +/** + * ufshcd_quirk_override_pa_h8time - Ensures proper adjustment of PA_HIBERN8TIME. + * @hba: per-adapter instance + * + * Some UFS devices require specific adjustments to the PA_HIBERN8TIME parameter + * to ensure proper hibernation timing. This function retrieves the current + * PA_HIBERN8TIME value and increments it by 100us. + */ +static void ufshcd_quirk_override_pa_h8time(struct ufs_hba *hba) +{ + u32 pa_h8time; + int ret; + + ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_HIBERN8TIME), &pa_h8time); + if (ret) { + dev_err(hba->dev, "Failed to get PA_HIBERN8TIME: %d\n", ret); + return; + } + + /* Increment by 1 to increase hibernation time by 100 µs */ + ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), pa_h8time + 1); + if (ret) + dev_err(hba->dev, "Failed updating PA_HIBERN8TIME: %d\n", ret); +} + static void ufshcd_tune_unipro_params(struct ufs_hba *hba) { if (ufshcd_is_unipro_pa_params_tuning_req(hba)) { @@ -8474,6 +8500,9 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba) if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE) ufshcd_quirk_tune_host_pa_tactivate(hba); + + if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_HIBER8TIME) + ufshcd_quirk_override_pa_h8time(hba); } static void ufshcd_clear_dbg_ufs_stats(struct ufs_hba *hba) diff --git a/include/ufs/ufs_quirks.h b/include/ufs/ufs_quirks.h index 41ff44dfa1db3..f52de5ed1b3b6 100644 --- a/include/ufs/ufs_quirks.h +++ b/include/ufs/ufs_quirks.h @@ -107,4 +107,10 @@ struct ufs_dev_quirk { */ #define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11) +/* + * Some ufs devices may need more time to be in hibern8 before exiting. + * Enable this quirk to give it an additional 100us. + */ +#define UFS_DEVICE_QUIRK_PA_HIBER8TIME (1 << 12) + #endif /* UFS_QUIRKS_H_ */ -- 2.39.5