Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp164641lqp; Wed, 22 May 2024 00:02:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsHJsBwz+0Mn8XdFyPLt4/07HP4pteFBRed6ScXFifXKhg4s4Ptpl1vpzcGyfEGutbYNnyBk/sxxZFk7IGRS9cd55fljvBXJNJCcyGEw== X-Google-Smtp-Source: AGHT+IGRQKUmk/ZAHO0I3KwX1YokkdC8Ewqny+FCd0ZxwJAQNQtZfMXtebwenQOIsxveIj4xm14E X-Received: by 2002:a05:6359:5f06:b0:186:131e:822 with SMTP id e5c5f4694b2df-19791dded6cmr100454155d.3.1716361357666; Wed, 22 May 2024 00:02:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716361357; cv=pass; d=google.com; s=arc-20160816; b=OO/cMhgQgEgFB3OJWdsjfh3SjMrhtVo1Ku50SW4lNVg2XxwROQN2aOIJ9ijjk+Tf5C nF/5A1YDGSd5NmkW2U8q4CezQNoNIPFtbK4zfK0qgp02FwVbdRpJDXjG80fmLvdyYnWo sMfbVILftUmrv9pdjRsMi36bLD3CXWtDfWsCuWWmuoOj3Lc5i1OoFulrzLKySM4M+CYb ZoSK2gL7lLGQx0p111V7e53oSGWTnysKJjG6EhAZTD2iz6opidI9HdOOTi9WACgOOmT5 Es6t91204fXdK4dBdkKgQf/clD/GNpNYygE/kSi2otg7TTnvhF+rudpCEQXx31Ef2SO0 44Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+RQpj1uiYR9HcyCBb06kV7GZV1kTw9b4x8ql1LSTPLs=; fh=1F8EIbaM8YeTankVzOwNjJdm0OSqbETX5uCxHegA1fU=; b=LJDW+YikfEPSe5l/xQ22/i+Yw4sokc/vvtV47OFSpA58b0cN6WCDYnMLqYQ8du3UR0 a5u25CdcsgwUrPYlpif4094c0rSWt9pqYxb6TZLcirdNlFmblqvRzqaajr6YrSKapuHq +cg1TYvsuxiTTxSB+vIlHguxjJYUboXvo6ACmPbmzAP9tkByANHzjTMeuPCxu+3ZK0PS SFTbARjnWI2rMhc6I2ad7itaNB/GYoqu/ZURricfKJOUZyOky0McCHi9Pwv2gqGV1m7C zOdTbv/BGwm2pEnDML1QrU3pt63xhEmSHiDwweV0OUVCUs9sjOb1GTpDl/CYSY9ST6tg QTPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DD+jnv9q; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-185832-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6640135fe26si7125602a12.838.2024.05.22.00.02.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 00:02:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185832-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=@quicinc.com header.s=qcppdkim1 header.b=DD+jnv9q; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-185832-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.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 2E5A1282551 for ; Wed, 22 May 2024 07:02:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 227687D3E0; Wed, 22 May 2024 07:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DD+jnv9q" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 E03067CF30; Wed, 22 May 2024 07:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716361336; cv=none; b=X27w4ynTI0Qr7pCTvESCXdGBrRo5HOL5+bpi5Xsva+A5oOMRrSxhmEg+GBgUFCqtaQVft/+M2d90KQSC36mozw+QPLu+z7+XyCY0lU2SDvWLQjy9qrKRYWdp+y07m1YuYer1FTBj5ELiMkjTQv2+aJTKDSordt67YFG4YKDK7jk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716361336; c=relaxed/simple; bh=fwaRCWvzPvI1UmPHLUZKAImIxm8Wv7EvZHtxRXetqwc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C/apSQHvfZUc3Mv4gCrU8VXJkBMI/NfRjeyCg42v+RGxpbcMXaQjzRH3i93J3MBAXoocbULjyq5rXWiP1H6c8VMCNfxYkIfFwIxLmYNnZHLGqz/OzRvocmQNHTlMkdIIRbDFN90IVwFhoZDGyJrs3/8g34fHaUaEK+MVXxAmAE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=DD+jnv9q; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M2lb74021188; Wed, 22 May 2024 07:01:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=qcppdkim1; bh=+RQpj1uiYR9HcyCBb06k V7GZV1kTw9b4x8ql1LSTPLs=; b=DD+jnv9qvMyi2gAG1UtqQhlmIjzS5CKTcKQT CCtrBkG92yP4bf3Ji57p+cWNIgU4i8SF4M4C9WbzcmQoHcTmALM62j4SAqqgEXei fSAyGIWZLS+oDv8W5Vvu4N8Dz5oV8mGhUC/mpfcOVzzrF025xoBT8CgZeLWjkFLL lbNHznu6RYCGrJNdGg39yVa+/vUxtHkKJT+3NPkSKkUQkCoC33FldXVMFV3WFcu7 Dj8HL+ERsqQZsWRQOb2VJF22GsLIcemJlkk2eqxF/3000iq7kiTXQqUd5MH8BPKp F7b7qg/fliOD2X9hLbacZJPbGwLE54pHbxNY5Wkoa6aSt3BDOQ== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6psnfyk4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 07:01:55 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44M71sBb015306 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 07:01:54 GMT Received: from stor-berry.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 22 May 2024 00:01:53 -0700 From: "Bao D. Nguyen" To: , , , , , , CC: , "Bao D. Nguyen" , Alim Akhtar , "James E.J. Bottomley" , Stanley Chu , Peter Wang , Manivannan Sadhasivam , Po-Wen Kao , Maramaina Naresh , open list Subject: [PATCH v1 1/2] scsi: ufs: core: Support Updating UIC Command Timeout Date: Wed, 22 May 2024 00:01:27 -0700 Message-ID: <292d7702e946ca513af51236ca9e38bf1b1eb269.1716359578.git.quic_nguyenb@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: sSGXS21wCljIOqtcj_TPU4pgcgI6DcKR X-Proofpoint-ORIG-GUID: sSGXS21wCljIOqtcj_TPU4pgcgI6DcKR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_03,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 adultscore=0 mlxlogscore=999 clxscore=1011 priorityscore=1501 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220050 The default UIC command timeout still remains 500ms. Allow vendor drivers to override the UIC command timeout if desired. In a real product, the 500ms timeout value is probably good enough. However, during the product development where there are a lot of logging and debug messages being printed to the uart console, interrupt starvations happen occasionally because the uart may print long debug messages from different modules in the system. While printing, the uart may have interrupts disabled for more than 500ms, causing UIC command timeout. The UIC command timeout would trigger more printing from the UFS driver, and eventually a watchdog timeout may occur unnecessarily. Signed-off-by: Bao D. Nguyen --- drivers/ufs/core/ufshcd.c | 9 ++++++--- include/ufs/ufshcd.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 21429ee..c440caf 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2460,7 +2460,7 @@ static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba) { u32 val; int ret = read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY, - 500, UIC_CMD_TIMEOUT * 1000, false, hba, + 500, hba->uic_cmd_timeout * 1000, false, hba, REG_CONTROLLER_STATUS); return ret == 0; } @@ -2520,7 +2520,7 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) lockdep_assert_held(&hba->uic_cmd_mutex); if (wait_for_completion_timeout(&uic_cmd->done, - msecs_to_jiffies(UIC_CMD_TIMEOUT))) { + msecs_to_jiffies(hba->uic_cmd_timeout))) { ret = uic_cmd->argument2 & MASK_UIC_COMMAND_RESULT; } else { ret = -ETIMEDOUT; @@ -4298,7 +4298,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) } if (!wait_for_completion_timeout(hba->uic_async_done, - msecs_to_jiffies(UIC_CMD_TIMEOUT))) { + msecs_to_jiffies(hba->uic_cmd_timeout))) { dev_err(hba->dev, "pwr ctrl cmd 0x%x with mode 0x%x completion timeout\n", cmd->command, cmd->argument3); @@ -10690,6 +10690,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3); } + if (!hba->uic_cmd_timeout) + hba->uic_cmd_timeout = UIC_CMD_TIMEOUT; + /* Hold auto suspend until async scan completes */ pm_runtime_get_sync(dev); atomic_set(&hba->scsi_block_reqs_cnt, 0); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index a35e12f..47e3bdf 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -917,6 +917,7 @@ enum ufshcd_mcq_opr { * @ufs_rtc_update_work: A work for UFS RTC periodic update * @pm_qos_req: PM QoS request handle * @pm_qos_enabled: flag to check if pm qos is enabled + * @uic_cmd_timeout: timeout in ms for UIC commands */ struct ufs_hba { void __iomem *mmio_base; @@ -1085,6 +1086,7 @@ struct ufs_hba { struct delayed_work ufs_rtc_update_work; struct pm_qos_request pm_qos_req; bool pm_qos_enabled; + u32 uic_cmd_timeout; }; /** -- 2.7.4