Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2704160lqz; Wed, 3 Apr 2024 06:25:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0awLbHMH9Q2BEnpY8U36wF9ItLDPmZ27s9CxmhtJrvnq6iFFIthCZbajCZ3y/WzXo30dfQImFkovVqhPhQSl+4oeF7uNV6vKbkQc70Q== X-Google-Smtp-Source: AGHT+IEYUmSUv70YrSReKB8cHymi1sqEAxTRsLhEiS5yGsTgs47F/VaO2vXZHG3kfsMWIV8/bAwy X-Received: by 2002:a17:906:b1c5:b0:a46:cee9:e412 with SMTP id bv5-20020a170906b1c500b00a46cee9e412mr9024602ejb.15.1712150733644; Wed, 03 Apr 2024 06:25:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712150733; cv=pass; d=google.com; s=arc-20160816; b=C71pL8ITZrVs5xdHBRrrl3XGafNijXCSKtpuWO4z0xJbnq51j6lo+qCca+XW88WIQT VfKWi9REVypGhCnjD2TSvTfXqF0vHtyH8v/oeb74AZrGlFQSOUwvudRGEbPw9AUZPW+x +MYuFV/ExK0ktYXJTv9+5m9hjk0MMPufgt4e2soH05BouiHLbybOCtgju4euGQGZjSAJ XIH3Qp9u7DOxemi7VjEPre1Nhl+YG5XqSyDLijOU/cL84Ri2IgulGZa1ZiszMYCLzqsZ FI++pmboOgM1gzLiVzkHJ2WKtqe3sTBs65+CowKApbYWOYHB/gy8E7sbLosLKroVcdkg e2BQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=KwQhYX2Mz1rNOgNCjbLm4vj/pn57/J/0LzejU91ZMaQ=; fh=li9arArfRQtEh9/JjbHtwTy8DSW51G90u8tUmvudW7s=; b=XIEBIpL1wnlKBR1PRw+k3oqm60NW5xMoFAZ4kBl+pxnJ5cNXZk6s9F5v2Y22Qf9pz+ Y0kjrTF27fIBabwH1sY1wdh+6zzORmNfLI4p4wfgWB76dElIFGPWbZqSr7TP1AKd0mPO GgGnVcBNNQp4SH027VBc7n1iYoMcVb1+wXG7rf/Pt+/lJtD8gA7hM6974Se7zThVneUK cQMUcFQ2jMhYVhtMf03J4aLKPVHPdQbR1A3uNooFbqflzZ2lork94LOJn82VWMCgqRsn mNLJ9wEvhxqKENjHXaE0VHM2dRtup2nb4mL+4ogYk6YGvkW14WhEbLXGMtAihx6KwjCK R5Kg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJ+YzJ1F; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-129820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gl19-20020a170906e0d300b00a467378f31dsi6645121ejb.490.2024.04.03.06.25.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:25:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJ+YzJ1F; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-129820-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129820-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 104A91F28914 for ; Wed, 3 Apr 2024 13:25:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1CC31514C5; Wed, 3 Apr 2024 13:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iJ+YzJ1F" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E7F7152163 for ; Wed, 3 Apr 2024 13:20:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150420; cv=none; b=YI/F/uDLapo56mhz8evEDvN2vMxgqKjCqfhsRxRYxI0JeTJ/EsQPWr4QNUYnx/ZqfVh7kHWTUt6GGDJ4tGDbZEMzciEh0F40egXU9CTwR2AgYiBuW7oT++XfL7Vyzvlad10SeNx6gRV6hnl8dr8U5MjvWutJCPfkKRrON8M2NT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712150420; c=relaxed/simple; bh=QMLyC7z7wrC4cQg2eqM+Dfe+kl12AbyhXTxgQxg+dJQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pWIlfwP1cAJpDLVmPZ4IazBCOP6/bHf/czegPm9WCDPr1sGVoE1wdKbYXIYSpT9lTEaD/rET7F/fGeEmvP+AYfJ7kcx9M1TlcXyL6Lzd/jPMXGorJKL+QNEj5orc8FnIhaIxDvjlwDQCP9y+yxKLoaCvH7xB+YnTaUgSz87gTWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iJ+YzJ1F; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6e8f765146fso5403521b3a.0 for ; Wed, 03 Apr 2024 06:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712150419; x=1712755219; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KwQhYX2Mz1rNOgNCjbLm4vj/pn57/J/0LzejU91ZMaQ=; b=iJ+YzJ1FnMTnDmmgSP+pBevtno1GL2cOETABb8IZDK3WtbxI2F5HAQNat8wZ0Z08Cj GlgfpFSI87gT5r9iV8b95Fn/8Jd83EfRVtuT49Ixsv8JhSQPz2WWWwWywoyUxBEET35n BHenb1XxJ/uD/tvhMScVHHbeHq3CNIZiuHHutjL8ro3pYV0EnBAf2g2EltTh7fPPqtZR abpg5hXaR0cJNVkD1ftYGKmu+qTKZa5PfackTYsD1FR0vpvCV/rgvCx2IMBbfQK6PlUK q+aJCV6jcocLsMaQxVLoE2pgd2roqIAj2XtyPARozxpFpeOorancxBXWXXUsHgxIZZ7t YXxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712150419; x=1712755219; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwQhYX2Mz1rNOgNCjbLm4vj/pn57/J/0LzejU91ZMaQ=; b=OksB44TJmTxw2RMYMt238ZSfL2UtrZLS8K/RJQILhUGJ1wjbOjFr7xNasyV64RIXor 9aVKhNOTrZk2ynIK4lnS/r6hNCyDE3TrFiKOxrQFNbHUXqaY23Nm3qOWFehME0QORG7Q RjVtC2kkiDCuYLS68V1kBWZPhetak5XYgMY9RN66aa3Q0Nj+sbINMMuz5fpql9t0FGIb a+6Ov4cNLguoXhaIr815mBA2Ka1NI2RHsjcTJmubtHhfPfY2zG0tuedGEXqt7dMJrk8o OtUEnK3YRmvrmmfBsuVAm2eclWGPKewsRRHNjZ9jgnAvfuUOQ5PvjcBDNU/e4GFyu8Hw VSlw== X-Forwarded-Encrypted: i=1; AJvYcCUoQVCsEo2xz4Bi6QQgjwu9rmQB4SQeLzqunc01+YGMMnIViQQ72qkzHowqJ0oGJpkyxPKxTgV9SmKWbNhOtuc8WTK0XRIRe93pT3Vf X-Gm-Message-State: AOJu0YwDF8e+u8IEAyckdsqMsIplILNARZ5/0LT9S3ttrm3SLNiu3tSt QkY8Oahlk3eKU4xA+JOjmtXTkfy17iB4mtKoGWnl7tGZSv+nm3mbIboQ6rP0uA== X-Received: by 2002:a05:6a00:8e06:b0:6e6:8c49:f2f6 with SMTP id io6-20020a056a008e0600b006e68c49f2f6mr16252144pfb.24.1712150418636; Wed, 03 Apr 2024 06:20:18 -0700 (PDT) Received: from [127.0.1.1] ([103.28.246.48]) by smtp.gmail.com with ESMTPSA id r1-20020aa78441000000b006e69a142458sm11640518pfn.213.2024.04.03.06.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:20:18 -0700 (PDT) From: Manivannan Sadhasivam Date: Wed, 03 Apr 2024 18:50:04 +0530 Subject: [PATCH v2 2/2] scsi: ufs: qcom: Add sanity checks for gear/lane values during ICC scaling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240403-ufs-icc-fix-v2-2-958412a5eb45@linaro.org> References: <20240403-ufs-icc-fix-v2-0-958412a5eb45@linaro.org> In-Reply-To: <20240403-ufs-icc-fix-v2-0-958412a5eb45@linaro.org> To: Bjorn Andersson , Konrad Dybcio , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1242; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=QMLyC7z7wrC4cQg2eqM+Dfe+kl12AbyhXTxgQxg+dJQ=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBmDVeJkgfnxTwqt6pwLJcFG/ywaqATm2PYnOmoZ 8RiTomJs4KJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZg1XiQAKCRBVnxHm/pHO 9WqlCACHiwIXIUVyW6PYemRimdhM9VGxKicBAzA1Xm4P8Jt7Xrv2D/sBmrrRoQ2ogK400Qpg9/G zyg6R9fpCortdbyi1rWC8JVtgeZGaM1GB1XeDq6Mdrtjt2nO41OaktIhw+oqtfSotEyBJCw13jb ItvI64Qq6igYPNiMd5WdO9Imo0yJuVQJ9tPcknCAHmzzWqCDDg7HaO03OJEjQf+O4KoU2WS2AOs 6pttNv6l5wDwvSzq19R1TG/eypF21m0hvxKRibAiKXO2TzqFtFndSI46tAIJd9zwxt3Kqx8pz/F bzI75lQksPSBnACjD+eg0zC78/FKcKIJFv622CeEIvRXX8nf X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 Let's add the checks to warn the user if the ICC scaling is not supported for the gear/lane values and also fallback to the max value if that's the case. Signed-off-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 696540ca835e..79b4ce05f7c5 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -696,6 +696,16 @@ static struct __ufs_qcom_bw_table ufs_qcom_get_bw_table(struct ufs_qcom_host *ho int gear = max_t(u32, p->gear_rx, p->gear_tx); int lane = max_t(u32, p->lane_rx, p->lane_tx); + if (WARN_ONCE(gear > QCOM_UFS_MAX_GEAR, + "ICC scaling for UFS Gear (%d) not supported. Using Gear (%d) bandwidth\n", + gear, QCOM_UFS_MAX_GEAR)) + gear = QCOM_UFS_MAX_GEAR; + + if (WARN_ONCE(lane > QCOM_UFS_MAX_LANE, + "ICC scaling for UFS Lane (%d) not supported. Using Lane (%d) bandwidth\n", + lane, QCOM_UFS_MAX_LANE)) + lane = QCOM_UFS_MAX_LANE; + if (ufshcd_is_hs_mode(p)) { if (p->hs_rate == PA_HS_MODE_B) return ufs_qcom_bw_table[MODE_HS_RB][gear][lane]; -- 2.25.1