From patchwork Mon Sep 9 23:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 827684 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 465C418D63B for ; Mon, 9 Sep 2024 23:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923520; cv=none; b=agrH4fmIC4C1Zg3fSL/seBfa9psaoSlqXmSz+mVwesFa4T4ThUnJZiWE0WcnXB1AXvsEsJdVDn+7/LYKND2zLXNYBxTg98n0fOck+WgYZc0WiDeMocARCa1hISaPsFHzbobYKeKfzA2XI1IZdkLjFcpbaTG1Hv+rpg3ZlQ/WFEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923520; c=relaxed/simple; bh=FddhbQfTp8v88Lur8UiiaU/Y+zXnAsClXr2EXxSAQUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iqpS+sNMzZkTy6g3inCxoPNN0Aj7hjiIae7CV0vt5LVmHkMY3zq/GKY/VLV7cId3SJSe3SGcXcEhcXOxJ94aJ1dN6DsuJCn3ERYOl0VNiZAVxrgouy4M7E/5CQywYlh0t2o4/GS1+ZzN1whUdluQU34zYAm7vXM5IQZEjaw8ib0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=a1SKazNI; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="a1SKazNI" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X2jJt55HDz6ClY8r; Mon, 9 Sep 2024 23:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725923515; x=1728515516; bh=EeN/B K4+bVHxC43DlnVycNpO9vP4PGo6gQmjRLawboY=; b=a1SKazNIMCF8r5S/B5NxF U22ZRtTufSTJuacQU9iZf+anR++L94Y1oSQqkpibrc5pk/xjiOJJfKZ2+gBj/W9G bH16w0toPrthMiIaKDrfperYgwI+gfn3ItCpYiNmzEnfD8tL9EhHybhH1nCvZqtU RH3ulaoDduEsvoTdPOTv9/3cnpxyM/SwQjcq5BjVX1YUCEegpC/SzDKgVby/vq2L qHrBSuCz27qVT8QvQlCZ+SUxsQhNMwDydywEjIGK6aVXTJEL4vuNz7rENMxI/QF+ oG7qYyhE/wM+kN9tLeCny+BhRo6gLE96MZ5Jg+fF0s9GLJgKp2m82nnh96fdS02d Q== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 3QdSdkZQqcno; Mon, 9 Sep 2024 23:11:55 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X2jJn0ZZWz6ClbFf; Mon, 9 Sep 2024 23:11:52 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Peter Wang , Manivannan Sadhasivam , Alim Akhtar , Eric Biggers , Minwoo Im , Avri Altman , Maramaina Naresh Subject: [PATCH v2 1/4] scsi: ufs: core: Improve the struct ufs_hba documentation Date: Mon, 9 Sep 2024 16:11:19 -0700 Message-ID: <20240909231139.2367576-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909231139.2367576-1-bvanassche@acm.org> References: <20240909231139.2367576-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make the role of the structure members related to UIC command processing more clear. Signed-off-by: Bart Van Assche --- include/ufs/ufshcd.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index a43b14276bc3..85933775c9f3 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -868,9 +868,10 @@ enum ufshcd_mcq_opr { * @tmf_tag_set: TMF tag set. * @tmf_queue: Used to allocate TMF tags. * @tmf_rqs: array with pointers to TMF requests while these are in progress. - * @active_uic_cmd: handle of active UIC command - * @uic_cmd_mutex: mutex for UIC command - * @uic_async_done: completion used during UIC processing + * @active_uic_cmd: pointer to active UIC command. + * @uic_cmd_mutex: mutex used for serializing UIC command processing. + * @uic_async_done: completion used to wait for power mode or hibernation state + * changes. * @ufshcd_state: UFSHCD state * @eh_flags: Error handling flags * @intr_mask: Interrupt Mask Bits From patchwork Mon Sep 9 23:11:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826853 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 44FD518C923 for ; Mon, 9 Sep 2024 23:12:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923529; cv=none; b=qrGVDf3ylcbUpxxIUuWuN/cQZVbdOCUJ9ZfyN5lPFGqP3ki0Ss3mvm3hSOzc7UMYjzWgtKjn+3YFEUO+emA0jU/GOzLT64/uCDeFE4PZBegAa5DlJZVUlq84pVPXKhHiwBgEwtGDx9nppHMHJB4XY2l4X3vQYk1KaDsxCSeZpDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923529; c=relaxed/simple; bh=vsAg+Zfo4QasgB3bQ181rEygWHkDaCVIGF2Y5YBKUdA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K5FSDuvYq/bPxHW7GCeLoQlw+44KwHgMX7mRmSxCjioKcnvb8O+m5JHC89rR/iw4Z8ouluIP67SLOGsOvg+AEUN66hAX72HSqbZtt7PSGePGeGlmFO6/FHbGnLN5O2KwPBy09+dr9Ne8cuTes3+nvpS0pNSqF+mtcTmxjZJPlTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=hhfG3u6b; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="hhfG3u6b" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X2jK35sc7z6ClY8w; Mon, 9 Sep 2024 23:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725923522; x=1728515523; bh=W6wt9 R1r1etqtJ7sorREhqWApOiurio2eN+3bU/Y6AU=; b=hhfG3u6btJZtymWybFq5J ULPHwtKdO3b9k0qRcOOOMDfqdf0ql5GFqj9N6Vnq6tIljVSL1unazFCZ6TXwSk4m nHmdSlMnpDE+wavHoMYeJhPmdBidaOleMyN4FW3A9MJUMeAlI11Sl4ZCuN2ht2Tg 5jLXp2ejLSWElCWTIA3W5JHigU2yoJnKs3qAVv/8t8MfHycabxZt/LqfdS3vmr3o hSvgwb16Yqm7uAdCtkTWNjAeXHMEB3KRzzs5cSaqJRcgeLrKcdDPuQySyNsAgEFs rRMzlL++VBdM6kDrtHZ/EgzsZm1+V0GWmIeYVm6PrAE5Z52kCzKG/Fjl+EhTO2aD A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id WRZ98tUmnQRL; Mon, 9 Sep 2024 23:12:02 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X2jJv4R3hz6ClbFf; Mon, 9 Sep 2024 23:11:59 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , Peter Wang , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , "Bao D. Nguyen" Subject: [PATCH v2 2/4] scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to read Date: Mon, 9 Sep 2024 16:11:20 -0700 Message-ID: <20240909231139.2367576-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909231139.2367576-1-bvanassche@acm.org> References: <20240909231139.2367576-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce a local variable for the expression hba->active_uic_cmd. Remove superfluous parentheses. No functionality has been changed. Reviewed-by: Bean Huo Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 8ea5a82503a9..134cba0ff512 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5458,31 +5458,30 @@ static bool ufshcd_is_auto_hibern8_error(struct ufs_hba *hba, static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) { irqreturn_t retval = IRQ_NONE; + struct uic_command *cmd; spin_lock(hba->host->host_lock); + cmd = hba->active_uic_cmd; if (ufshcd_is_auto_hibern8_error(hba, intr_status)) hba->errors |= (UFSHCD_UIC_HIBERN8_MASK & intr_status); - if ((intr_status & UIC_COMMAND_COMPL) && hba->active_uic_cmd) { - hba->active_uic_cmd->argument2 |= - ufshcd_get_uic_cmd_result(hba); - hba->active_uic_cmd->argument3 = - ufshcd_get_dme_attr_val(hba); + if (intr_status & UIC_COMMAND_COMPL && cmd) { + cmd->argument2 |= ufshcd_get_uic_cmd_result(hba); + cmd->argument3 = ufshcd_get_dme_attr_val(hba); if (!hba->uic_async_done) - hba->active_uic_cmd->cmd_active = 0; - complete(&hba->active_uic_cmd->done); + cmd->cmd_active = 0; + complete(&cmd->done); retval = IRQ_HANDLED; } - if ((intr_status & UFSHCD_UIC_PWR_MASK) && hba->uic_async_done) { - hba->active_uic_cmd->cmd_active = 0; + if (intr_status & UFSHCD_UIC_PWR_MASK && hba->uic_async_done) { + cmd->cmd_active = 0; complete(hba->uic_async_done); retval = IRQ_HANDLED; } if (retval == IRQ_HANDLED) - ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd, - UFS_CMD_COMP); + ufshcd_add_uic_command_trace(hba, cmd, UFS_CMD_COMP); spin_unlock(hba->host->host_lock); return retval; } From patchwork Mon Sep 9 23:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 827683 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 1BC428F5A for ; Mon, 9 Sep 2024 23:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923535; cv=none; b=FWfzOJzJu80ndVtBBXVQBILmyW6MP0NQroIRRaFu0QIBJ4QfV5Tu/E/24lF/JPdLSVIY29y71HjsBL76OpBWtiUDDOdJ1gOIczBoeu7kmdTMGS+FaXlc0WUFUZEnKmJsrr7EMvVEwh05UGDaB+gID9pfCW7WXv0kmqqcVJma2C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923535; c=relaxed/simple; bh=/GrVkqcOQcEAjoDpUDF+HrT+4BRTLzWPBj7iNyrGyIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pAXroLGVJnct9qgASlcpITlh4maxSCN9xbng21eKTgR6lSMFnjrXaYtB9OPYySkNmffE2zzHIIVD6+aPxhswqqyRmg5BTR75XBe85P0NSOa3pzBmHRD/NFU4B+1EcQXKhVeI7a9uTeVoSrGbJN0wVsY1rCT53L/wz1HSIOnlwYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=xY5CkCa7; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="xY5CkCa7" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X2jK94KyZz6ClbFf; Mon, 9 Sep 2024 23:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725923528; x=1728515529; bh=SvXMJ iPZBHoU6aPNCnj3gufXyHHgjWrutRYVZ73EKeE=; b=xY5CkCa7VSDpISQly4I5u lSN8WbDBvE9JoywRgkZMjvwb8L0ifjSiGxm0xiBRUV6ggGZG3vdy3XsjFyI0r6qK 9O36uZAipm+MVBDUqUpyuj8XyK1VU/OAI6Hs7MJZPY6sGfcqL60a/mPgqsoq8Nk+ +18v3iTd59N4nyKkLocFL/Wt+K6vXrnK8ppBWr3trrdlItp1nSseVbm2H2c7zxH4 NWndL061jsom6p2qTqPsm1yZX8Y0qPeUehrLx3Au80QjUB6t7eSqXU1AU82aD3e+ 84Jc03RMhZ0mydQvrP3o9p1q6U06ksWgbfpiFxhaRQWWPxqKPn3i8jy3Lct/o8pH A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id JfjwWVZUbmkg; Mon, 9 Sep 2024 23:12:08 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X2jK23NGCz6ClY8r; Mon, 9 Sep 2024 23:12:06 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo , "Bao D. Nguyen" Subject: [PATCH v2 3/4] scsi: ufs: core: Always initialize the UIC done completion Date: Mon, 9 Sep 2024 16:11:21 -0700 Message-ID: <20240909231139.2367576-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909231139.2367576-1-bvanassche@acm.org> References: <20240909231139.2367576-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify __ufshcd_send_uic_cmd() by always initializing the uic_cmd::done completion. This is fine since the time required to initialize a completion is small compared to the time required to process an UIC command. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 134cba0ff512..063fb66c6719 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2537,13 +2537,11 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) * __ufshcd_send_uic_cmd - Send UIC commands and retrieve the result * @hba: per adapter instance * @uic_cmd: UIC command - * @completion: initialize the completion only if this is set to true * * Return: 0 only if success. */ static int -__ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, - bool completion) +__ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { lockdep_assert_held(&hba->uic_cmd_mutex); @@ -2553,8 +2551,7 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, return -EIO; } - if (completion) - init_completion(&uic_cmd->done); + init_completion(&uic_cmd->done); uic_cmd->cmd_active = 1; ufshcd_dispatch_uic_cmd(hba, uic_cmd); @@ -2580,7 +2577,7 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) mutex_lock(&hba->uic_cmd_mutex); ufshcd_add_delay_before_dme_cmd(hba); - ret = __ufshcd_send_uic_cmd(hba, uic_cmd, true); + ret = __ufshcd_send_uic_cmd(hba, uic_cmd); if (!ret) ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd); @@ -4270,7 +4267,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) reenable_intr = true; } spin_unlock_irqrestore(hba->host->host_lock, flags); - ret = __ufshcd_send_uic_cmd(hba, cmd, false); + ret = __ufshcd_send_uic_cmd(hba, cmd); if (ret) { dev_err(hba->dev, "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", From patchwork Mon Sep 9 23:11:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 826852 Received: from 008.lax.mailroute.net (008.lax.mailroute.net [199.89.1.11]) (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 B46A918C923 for ; Mon, 9 Sep 2024 23:12:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923553; cv=none; b=i94p8hZcyOyzMqbGooorW9Yo1IkD3do1xwMGSg9uQzTIaX8iPsKOAj8omG5fCNeNfvnwSMCGWLemVQERn6oviffpDi4bMxnul/2Cqisz/Zt6i8FM4MNckyxppsUaItyVdCd0A+7Xa4o95733upASGzOAZzqk6l5nhlZk4vtT32A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725923553; c=relaxed/simple; bh=YuV+NBhRWZ0+Ju05pPKOKvV4OPwHU+oS4simsOP6uh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AufBPYc2nQIso52j996ew3+FIu7VitBbbzz06ockDzpQbZSBk62UTEuRb/iVY2wd9InpIPSbSnJnm2Y7gUNZyhv5x3zOrCG43t6yzIWOfxl5/Y17H8BJ3km2a4iQMY4lg9L/e/FVrL46nAaqGb5Xf0xeju7+t07y9sYLlTd5h1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=0YS1rubo; arc=none smtp.client-ip=199.89.1.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="0YS1rubo" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X2jKV37H9z6ClY8r; Mon, 9 Sep 2024 23:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1725923539; x=1728515540; bh=xDxE2 jiqdBmZDnXQVLEd0lngtHNP+7y0ubPOaeXCuP8=; b=0YS1rubofzzybduVfVS3p OEAOAe/RTUxgpyzLLGh3dkDGVQREruGNLndcm7U9P0kct7wJ5FYf3iAxGgfJI4UM UM7ZXdwB5u0+BAGYX3nDdmbBuzAc/N+Ca6OkXWg0GBm1LINPkVobZJRg9OqLnJmQ DGXD8QvcySs5/69wC9OWIp1WNI/URF4sA7NOu1orYjKTp2ruy0cUbLPLJiDkA3PD 01As9+fYUfnuUKNMQHzHDRgUmkTfaxxJkOfVaZtV1f8NsZfFycnG5QGwVZBApiPg K3pXpCDpj1HIBE/kBnYbC0P1ecuJcEYOhjBNFitfoONxtct4uT8dAkaWxB0SWLll A== X-Virus-Scanned: by MailRoute Received: from 008.lax.mailroute.net ([127.0.0.1]) by localhost (008.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id EGicCzSQkOOi; Mon, 9 Sep 2024 23:12:19 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 008.lax.mailroute.net (Postfix) with ESMTPSA id 4X2jKD1CsVz6ClbFf; Mon, 9 Sep 2024 23:12:15 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Peter Wang , Manivannan Sadhasivam , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Andrew Halaney , Bean Huo , "Bao D. Nguyen" , Alim Akhtar , Eric Biggers , Minwoo Im , Maramaina Naresh Subject: [PATCH v2 4/4] scsi: ufs: core: Change the approach for power change UIC commands Date: Mon, 9 Sep 2024 16:11:22 -0700 Message-ID: <20240909231139.2367576-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909231139.2367576-1-bvanassche@acm.org> References: <20240909231139.2367576-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For some host controllers it is required that UIC completion interrupts are disabled while a power control command is submitted while for other host controllers it is required that UIC completion interrupts remain enabled. Hence introduce a quirk for preserving the current behavior and leave UIC completion interrupts enabled if that quirk has not been set. Although it has not yet been observed that the UIC completion interrupt is reported after the power mode change interrupt, handle this case by adding a wait_for_completion_timeout() call on uic_cmd::done. Note: the code for toggling the UIC completion interrupt was introduced by commit d75f7fe495cf ("scsi: ufs: reduce the interrupts for power mode change requests"). Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 15 ++++++++++++++- drivers/ufs/host/ufs-mediatek.c | 1 + drivers/ufs/host/ufs-qcom.c | 2 ++ include/ufs/ufshcd.h | 6 ++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 063fb66c6719..23cd6f4a6ca2 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4257,7 +4257,8 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) goto out_unlock; } hba->uic_async_done = &uic_async_done; - if (ufshcd_readl(hba, REG_INTERRUPT_ENABLE) & UIC_COMMAND_COMPL) { + if (hba->quirks & UFSHCD_QUIRK_DISABLE_UIC_INTR_FOR_PWR_CMDS && + ufshcd_readl(hba, REG_INTERRUPT_ENABLE) & UIC_COMMAND_COMPL) { ufshcd_disable_intr(hba, UIC_COMMAND_COMPL); /* * Make sure UIC command completion interrupt is disabled before @@ -4275,6 +4276,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) goto out; } + /* Wait for power mode change interrupt. */ if (!wait_for_completion_timeout(hba->uic_async_done, msecs_to_jiffies(uic_cmd_timeout))) { dev_err(hba->dev, @@ -4291,6 +4293,17 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) goto out; } + if (!reenable_intr) { + /* Wait for UIC completion interrupt. */ + ret = wait_for_completion_timeout(&cmd->done, + msecs_to_jiffies(uic_cmd_timeout)); + WARN_ON_ONCE(ret < 0); + if (ret == 0) + dev_err(hba->dev, "UIC command %#x timed out\n", + cmd->command); + ret = 0; + } + check_upmcrs: status = ufshcd_get_upmcrs(hba); if (status != PWR_LOCAL) { diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 02c9064284e1..4e18ecc54f9f 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1021,6 +1021,7 @@ static int ufs_mtk_init(struct ufs_hba *hba) hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL; hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR; hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC; + hba->quirks |= UFSHCD_QUIRK_DISABLE_UIC_INTR_FOR_PWR_CMDS; hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80); if (host->caps & UFS_MTK_CAP_DISABLE_AH8) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 810e637047d0..07a62de80d2e 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -852,6 +852,8 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba) { struct ufs_qcom_host *host = ufshcd_get_variant(hba); + hba->quirks |= UFSHCD_QUIRK_DISABLE_UIC_INTR_FOR_PWR_CMDS; + if (host->hw_ver.major == 0x2) hba->quirks |= UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION; diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 85933775c9f3..787c44a341a7 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -676,6 +676,12 @@ enum ufshcd_quirks { * the standard best practice for managing keys). */ UFSHCD_QUIRK_KEYS_IN_PRDT = 1 << 24, + + /* + * Disable the UIC interrupt before submitting any power mode change + * commands. + */ + UFSHCD_QUIRK_DISABLE_UIC_INTR_FOR_PWR_CMDS = 1 << 25, }; enum ufshcd_caps {