Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1335903lqb; Thu, 30 May 2024 07:27:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfLvdCzTGYFUon3ppwVVX8upFi1v138+e5/QV65weKccJX2k0qUfW34r/mCEscuaCgkWc1DRmJn7nPCpjj0ztpl7tjDR4kw0QEV7CJRg== X-Google-Smtp-Source: AGHT+IERljnrj9E4k/wBEwRI6NPPkFHdWZPBX6eBzvIHpmekhWZhLWflXn5pr/kDi3lcnjZAYGVx X-Received: by 2002:a17:902:ec92:b0:1f3:62c:247f with SMTP id d9443c01a7336-1f61be15ccemr30271285ad.11.1717079252356; Thu, 30 May 2024 07:27:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717079252; cv=pass; d=google.com; s=arc-20160816; b=nz0Ga1ADc6LVkJ1RyBsYvhhvuyAvqz18UFYgoDgPLim0LtdtT0KYOsFxOmNSKTtpGb kRJV4+PlvUhAksWZ3AgYa8NKUIUXLW5KRH10Q/vbMj8/yEQv8Jn6OfKbFKxwZ+t6D+4T NoyVT63lLG0l1UsVYUK4MyWnDfCz94F5Au3i4POWxGyvptiersP/EBvzdO6tBH+paqRR HW+ef9uFIthESoHCgTjHGa4esdsBp7AWV4p2uive/ewmxkKuXbST37MsXcDSJgF7TjMo 6cQiNUB36caymyHwH78pofHnUilT5ByiWWclPWD4rqPfsaicwske5NvVSHCGxW/XdsSg npPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:wdcironportexception:ironport-sdr :dkim-signature; bh=UmoGXWt/A1gCtMC9nMiYr8eeOf3mdG8c3APcClEFNO8=; fh=X0Lb6G6jJE8+QeYtFGxv2g5f8eI/IotqH0fFq08ifqY=; b=rSYLy+kxTxdv4P1SqERranJ20fu9GFAFQvVW8l7uQKjAepA35xsdnhWqnpvnT0ZttP AFPWz96Ot1223XP9XBEOfbYKcW/Ri8VAtv2g1Uy6W9UdebcYR9+gNktBQ8k19oQo57ZC HwNyKPmj6+6/0Q2wpntJBaV/8YnCZp9c+64owD0V7TT71L+bfroTs25/7+um8vbJQGKn FkIa0c3A8U63YMzNhh/U/rxMz8QCXBJdu6V84auvOg5uccu+8JB07SRn2gZgm5dTW0vd WEcFpFdN7YhOh11X/rT1eJSeI8tvlXiTse7eUYwyMY4UjsUYF5MkjPa9ZZuqnRfqbuzX pVLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=Be2n5Pib; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-195518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c970cedsi123975735ad.231.2024.05.30.07.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 07:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=Be2n5Pib; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-195518-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195518-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DBFE2283C93 for ; Thu, 30 May 2024 14:26:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29DCE17F4F3; Thu, 30 May 2024 14:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Be2n5Pib" Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) (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 3D63817D8B3; Thu, 30 May 2024 14:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.141.245 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717079132; cv=none; b=hDX2DaS/qbRLs6XZfTB+OvAl2VmIKIwu2WE32w5SWgZxt/+vO9xk5gBFvVh4+MWym9hE7ioZpUqBMVLJ+v2ceZQwZhbu03xtOxnigDP8sSzPTfPKOzBz7fLm6R4kCKwut526OIqDYunCSBe9N5ZIDHRLJx/5mQNwGvP1KUq5yNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717079132; c=relaxed/simple; bh=jLpvsRdj6MFssffe0kGVr3EfO+1vX9Uwo/mP6AmpF74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J4PYS5rM+rXk4Lne5y3u55MLBPGCYbfUvquLaj8pTymMmAE8Ajj9Ee1YrEpXVuFrddfJWfcrLXLqpgeK31NS880fzZFo3iljnmrcrYyRIMTmF++AAK5mYMcAjUGFuG770tmLxFScsicsoDcfTqDYdl6BMVDDv7soIJgQjwiEuqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=Be2n5Pib; arc=none smtp.client-ip=68.232.141.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1717079130; x=1748615130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jLpvsRdj6MFssffe0kGVr3EfO+1vX9Uwo/mP6AmpF74=; b=Be2n5Pib87ypZdMod6TbqO0NT+mw6owLOFn9BEJBhEPgvOD6EbMLi4oW LvJedSrmSvmUzry3YyI64WNW76qrClIKRhg2BvfNFFbZ9d7t+wSZvYeMP lG73wOzfK/BhXJryr2zTmVEQBgsl8L7g3mlmWipxtr7B3UXPjTAgGTeBx RJRq1Kb/+xcbpOLZwwDmefQSespQwxQkzOmRizT3fmJO+2he7+LhB+BFo CXIgeet8cZtoAmFFN47F9S+9kfndyZB+1CxSOt+H3ly47l58wW2wSoCiF 3vm2zx4+EsCpkGzhdsmf40icNVgJwuDmGwAA//Ws5FL6JHFknGM4sfnvP Q==; X-CSE-ConnectionGUID: xCcKWqpAS0yxH9k4zDdl6Q== X-CSE-MsgGUID: 7q9I2+qbTwOGbX09si9ZCw== X-IronPort-AV: E=Sophos;i="6.08,201,1712592000"; d="scan'208";a="17923534" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 May 2024 22:25:25 +0800 IronPort-SDR: 66587eaf_kJVo94h44/miQr20I/Av+bxm5tBwMMMueIVl/Evuo48HanL s67xCKdUR1/64B/1mfwvuneEk924v+6Lrf81R7w== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 May 2024 06:27:12 -0700 WDCIronportException: Internal Received: from bxygm33.ad.shared ([10.45.31.229]) by uls-op-cesaip01.wdc.com with ESMTP; 30 May 2024 07:25:24 -0700 From: Avri Altman To: "Martin K . Petersen" Cc: Bart Van Assche , Bean Huo , Peter Wang , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Avri Altman Subject: [PATCH v7 2/3] scsi: ufs: Maximum RTT supported by the host driver Date: Thu, 30 May 2024 17:25:08 +0300 Message-ID: <20240530142510.734-3-avri.altman@wdc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240530142510.734-1-avri.altman@wdc.com> References: <20240530142510.734-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Allow platform vendors to take precedence having their own max rtt support. This makes sense because the host controller's nortt characteristic may vary among vendors. while at it, set this value for Mediatek, as requested by Peter - https://lore.kernel.org/all/0a57d6bab739d6a10584f2baba115d00dfc9c94c.camel@mediatek.com/ Signed-off-by: Avri Altman Reviewed-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 5 ++++- drivers/ufs/host/ufs-mediatek.c | 1 + drivers/ufs/host/ufs-mediatek.h | 3 +++ include/ufs/ufshcd.h | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index dda6d7e44436..41bf2e249c83 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8131,6 +8131,8 @@ static void ufshcd_set_rtt(struct ufs_hba *hba) struct ufs_dev_info *dev_info = &hba->dev_info; u32 rtt = 0; u32 dev_rtt = 0; + int host_rtt_cap = hba->vops && hba->vops->max_num_rtt ? + hba->vops->max_num_rtt : hba->nortt; /* RTT override makes sense only for UFS-4.0 and above */ if (dev_info->wspecversion < 0x400) @@ -8146,7 +8148,8 @@ static void ufshcd_set_rtt(struct ufs_hba *hba) if (dev_rtt != DEFAULT_MAX_NUM_RTT) return; - rtt = min_t(int, dev_info->rtt_cap, hba->nortt); + rtt = min_t(int, dev_info->rtt_cap, host_rtt_cap); + if (rtt == dev_rtt) return; diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index c4f997196c57..c7a0ab9b1f59 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1785,6 +1785,7 @@ static int ufs_mtk_config_esi(struct ufs_hba *hba) */ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .name = "mediatek.ufshci", + .max_num_rtt = MTK_MAX_NUM_RTT, .init = ufs_mtk_init, .get_ufs_hci_version = ufs_mtk_get_ufs_hci_version, .setup_clocks = ufs_mtk_setup_clocks, diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h index 3ff17e95afab..05d76a6bd772 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -189,4 +189,7 @@ struct ufs_mtk_host { /* MTK delay of autosuspend: 500 ms */ #define MTK_RPM_AUTOSUSPEND_DELAY_MS 500 +/* MTK RTT support number */ +#define MTK_MAX_NUM_RTT 2 + #endif /* !_UFS_MEDIATEK_H */ diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index d74bd2d67b06..ef04ec8aad69 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -295,6 +295,7 @@ struct ufs_pwr_mode_info { /** * struct ufs_hba_variant_ops - variant specific callbacks * @name: variant name + * @max_num_rtt: maximum RTT supported by the host * @init: called when the driver is initialized * @exit: called to cleanup everything done in init * @get_ufs_hci_version: called to get UFS HCI version @@ -332,6 +333,7 @@ struct ufs_pwr_mode_info { */ struct ufs_hba_variant_ops { const char *name; + int max_num_rtt; int (*init)(struct ufs_hba *); void (*exit)(struct ufs_hba *); u32 (*get_ufs_hci_version)(struct ufs_hba *); -- 2.34.1