From patchwork Thu Sep 12 00:30:46 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: 828866 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 04A64257D for ; Thu, 12 Sep 2024 00:31:18 +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=1726101080; cv=none; b=b7YfT6V7ARKIuPnsOejd7P2y2MWQSrbsGkoLw+ojygb6EfOgrAvFhEW+sTHZr/RNAoDxpCG1adXy8LlyCU6NOCGzuYIkgBsv1rA+G4T1nnJGaDqUsRhSgYK7PdJCB9DoKxjSGUKZKQqGEU/qYY+qHcp0IG2PVNiFh5YsYf8caQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726101080; c=relaxed/simple; bh=zKJfrLeoBPPI3uHpNP+FXEv5R0/yEhtRTKeW7bWtfzA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NwQJ2k+BKN6SjeMh9Myye70z9Iz2wLNxyTv8ejvwv1aaRkS+z61f2QATwq4ylkhRFttQqcEuuDGCaDLngdRsJ3JXpFNbDaTuGfTcBJoIdyJqV2dpJLOm6lnapGnc16AmaiYiHO6/sSG1umUSukVcPUycsb6QRvQbHcc4IoDA2wY= 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=aZ3Aquly; 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="aZ3Aquly" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X3yzV2Zlxz6ClY9R; Thu, 12 Sep 2024 00:31:18 +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=1726101073; x=1728693074; bh=M602l HejhFAGmvvzqGitnCXvr6yptgiUPr9f9z3DINk=; b=aZ3AqulykLIm1Ztm0MgMb tWoDeZdpZ8XiXZWjLItWrTGZFbkW19uw9K7yuQI3t6W+nJ5+64lP++q5gbuG8Tu7 9TZR+pu3WVTMgx81Y3mbhKjUpRor/3eKmK/1hzuKpG5CdZ/3Txw4lDJrIlomYZy/ QCrLIQdRmiL5UA2alAH//NUf45PeTXDlKi76GD8GADGp7GcnUjyD9vBN6QrnAtjo zJD+UFpwQ3yDFKP4DF9+760/BQiLBm/ew30E4ZsC55W91x+1wOVXNGW9O51Ls6Zh uqn3EmNcm3eNGq+IUKjQAcM/PLGG/n2Np4oap5vclUQzLw1a4lt4g5kelNeXiGJE g== 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 FUF77uE9cTuV; Thu, 12 Sep 2024 00:31:13 +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 4X3yzN4gkcz6ClY9K; Thu, 12 Sep 2024 00:31:12 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Peter Wang , Matthias Brugger , AngeloGioacchino Del Regno , Manivannan Sadhasivam , Alim Akhtar , Eric Biggers , Minwoo Im , Avri Altman , Maramaina Naresh Subject: [PATCH v3 1/4] scsi: ufs: core: Improve the struct ufs_hba documentation Date: Wed, 11 Sep 2024 17:30:46 -0700 Message-ID: <20240912003102.3110110-2-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240912003102.3110110-1-bvanassche@acm.org> References: <20240912003102.3110110-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. Reviewed-by: Peter Wang 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 Thu Sep 12 00:30:47 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: 828086 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 263612570 for ; Thu, 12 Sep 2024 00:31:24 +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=1726101086; cv=none; b=VgbeovXg+W6ebPN5ZoBqWHA2x/acA/5IRs6uKJoIHeGBpBSwumwkMJBKyaazrrFeTi0La/Zpz9qBXDULoY42ozC4zb6r+Q9lDLUK6m8ZyroCJKkajKo9A9rIh3aY38voyoqm4w+7yNtKrZsJgfgKfB0Paj38I48kxrj5/I1dVVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726101086; c=relaxed/simple; bh=vsAg+Zfo4QasgB3bQ181rEygWHkDaCVIGF2Y5YBKUdA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IdcufDlwwgz7igj7UWfAa3xfZjGAP8N3sdI3gX6dIVwGrP0g8G7vuux3XGU+AhkfCwe5QgbP1fadqXeS+n8JsaKgP3oDkAEgW5H+lgggWgIxkhLDn08TT/pQKkZD3zkht+VRTBtrkGyocEPz0QUpTfsPjaQsZcIHrx2k+TBp0YY= 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=C+uk6FG9; 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="C+uk6FG9" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X3yzc4GCJz6ClY9R; Thu, 12 Sep 2024 00:31:24 +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=1726101078; x=1728693079; bh=W6wt9 R1r1etqtJ7sorREhqWApOiurio2eN+3bU/Y6AU=; b=C+uk6FG9YQQnh4sObSOnr bdPoKy3AMqYzOs1gjt8ta7FKdLAkvrO2QsgipdbnxQodf/VX1nmStz/1Wtk74FT8 /AtpH8mazbAmpDTktWO4hJVraHFiAHNRrx8mpMcxX5lvfLEUtyIrW877H/XNiOCy S1kf4WCXLY1Z5CSvHUxMGn3SNODJov4DjiuIZHrSGA9Z8sTJfClrgbpA7hoZX0Q/ cmB2pJQVQFSAxIV/cZrmgWXY8zwRsGLdMBMA6SLLkkUK1I4d7XRlmZvxN16REh8n G99Z+1lj0lP+MQBOn6KzbBFuKQSG2kT/V1xgoJL5qz6V4nc59McfqFOX5VMFeUlM 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 Ifql6Rdpi4iX; Thu, 12 Sep 2024 00:31:18 +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 4X3yzT51rfz6ClY9P; Thu, 12 Sep 2024 00:31:17 +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 v3 2/4] scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to read Date: Wed, 11 Sep 2024 17:30:47 -0700 Message-ID: <20240912003102.3110110-3-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240912003102.3110110-1-bvanassche@acm.org> References: <20240912003102.3110110-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 Thu Sep 12 00:30:48 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: 828865 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 CEB105684 for ; Thu, 12 Sep 2024 00:31:27 +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=1726101089; cv=none; b=Doxa14v1dTBsoKT2E1ixWxifDx7LcsRoTv2oIpfZ4275upFXKzGWTTp8o83HIQZitE+IynaX0OrnqUf+XLpYqsl6gWmgrGe6sAJbjTSzcGMfR3RSw5bDX+OARnWbpzrEZ2CstMDJbwqBFzJUzl8lATvMJdp0SHuMhec37kdjWh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726101089; c=relaxed/simple; bh=3StelB+OMxZvrOslTKx1BGcXrp0fdmzFNI3GQu30oiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AH/apw/eZoF4CiRV18YT3+rFfQPgjA1mpUnSi6bw8/cuAgV9HUCOMOIti2V4SiL3j0l/4mKsX7bLKvwAwAvPhv312FMnoOEr6Ax8Yc11CHe+81GuKQA5NzGvvXspOsyPIOjLkEUkyPbpGAwpH+fehG/U9c0JNl/dsod/aZwONJw= 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=M5k4dkgR; 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="M5k4dkgR" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X3yzg4Cfwz6ClY9R; Thu, 12 Sep 2024 00:31:27 +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=1726101083; x=1728693084; bh=MZuqY m1wzEII0tIbL7jkYNJTnU9MWqLzTZimNWxUcIs=; b=M5k4dkgReyO6eNrnXSAzP AFlTv59lv192Q6NR4EOw5Ww2cIq6eolEk6rbLHpLyPLbQXL/DRhUUK6akibDucvP 2tFruPGQHw1BudVsJopOxrg7YxsQzjij9w2ncmsId80x4+Qll8ulrk5j7r6joaFR tNBztTfcon/nnPSmQFDl7RAf+G0wazTLZYa79HCLYKjgwu3nkIwbOjTe8HadUEsg +cPzIT4y9i5/pNmA1SofyliLX/ca+9zXn4+1sbG9PHRSJYh/7GzxHTA9Zi4WswOP Tj0LOGyOgZq5nbfNKp74qYs9aLBJWJTa7fWNbnsD3zYEfPJpYOt/IDefi0Npazdy 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 PCKA0WooIsHK; Thu, 12 Sep 2024 00:31:23 +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 4X3yzZ3nkFz6ClY9K; Thu, 12 Sep 2024 00:31:22 +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 v3 3/4] scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to analyze Date: Wed, 11 Sep 2024 17:30:48 -0700 Message-ID: <20240912003102.3110110-4-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240912003102.3110110-1-bvanassche@acm.org> References: <20240912003102.3110110-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In ufshcd_uic_cmd_compl(), there is code that dereferences 'cmd' with and without checking the 'cmd' pointer. This confuses static source code analyzers like Coverity and sparse. Since none of the code in ufshcd_uic_cmd_compl() can do anything useful if 'cmd' is NULL, move the 'cmd' test near the start of this function. Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 134cba0ff512..bd4ce3395972 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5462,10 +5462,13 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) spin_lock(hba->host->host_lock); cmd = hba->active_uic_cmd; + if (!cmd) + goto unlock; + if (ufshcd_is_auto_hibern8_error(hba, intr_status)) hba->errors |= (UFSHCD_UIC_HIBERN8_MASK & intr_status); - if (intr_status & UIC_COMMAND_COMPL && cmd) { + if (intr_status & UIC_COMMAND_COMPL) { cmd->argument2 |= ufshcd_get_uic_cmd_result(hba); cmd->argument3 = ufshcd_get_dme_attr_val(hba); if (!hba->uic_async_done) @@ -5482,7 +5485,10 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) if (retval == IRQ_HANDLED) ufshcd_add_uic_command_trace(hba, cmd, UFS_CMD_COMP); + +unlock: spin_unlock(hba->host->host_lock); + return retval; } From patchwork Thu Sep 12 00:30:49 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: 828085 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 88C697462 for ; Thu, 12 Sep 2024 00:31:34 +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=1726101096; cv=none; b=eoGhszzQo7Tddk0uWzJ7akLpHRRCDGMOqrm5WhkQdIT4CSXOX30hMNenfx6DonNt8CssSuGklmqSC8X1orYN95xWvihfoF/W+rbXVIa1PsZNex/B5SjhB8JU1KzSbiN9K+bOly2jOQoGUhOMV3tasH3ORssTqDqlPVHw/VcTf2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726101096; c=relaxed/simple; bh=iL10mvZ/hPyQAlt4pagDqx7HlwgXXZoSyRrQ9qzqgaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MaG6MdlZMvM8BkMTtU88jENIUV7aVXLguImPTrTJfmSAegEqz5z47I4D8ItHl3npHtIG0KnM1yh3M56VkEteR/7J/BcjJTnAOpdbCsRCvhoL5eCX32fW1fNRnlUrZrD3p76LN1X72rDeMPt/kKpn4HagaY/hoN+RP+N6aimLk+s= 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=pyuIiUOA; 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="pyuIiUOA" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4X3yzp0B5dz6ClY9K; Thu, 12 Sep 2024 00:31:34 +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=1726101088; x=1728693089; bh=hKyxm mcs8Df3jZ3u5AaT4nWNnxZMoPbKHs1qlSggf2c=; b=pyuIiUOAFWuZvJeGmOa/f w2xMOWDl48Mg5UmmDiJxszPnJbgXk42E5fCbzdIwk3mFiy76iqwzwlFwCHeH3Fzs xsAFA7axoDYrB37E1KZWvrfxVCl3NZQQ4kGuA6xoFPjW10Qyk1QblIVRgs8r13LA 0eVDRT/YRpgpTQAj0laJ+EiYvGxB4WMrp5YYnHiLRJbW6+7Pl+6LKH/ifgjLMsM4 72NaumwLDmCu4n367kQ+QnCxJB+ufjZBM6xVl6fO4otOm54Jr6G1vjqr9RxQ+bRe M2tYLopqIs/cl7e4JE2kBFnkbe/N4U4BsUSA6QmA88wBct54uk6xlWtf0NweMwaF w== 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 pzQHYN-L2Nea; Thu, 12 Sep 2024 00:31:28 +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 4X3yzg1NVsz6ClY9P; Thu, 12 Sep 2024 00:31:27 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Peter Wang , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Manivannan Sadhasivam , Avri Altman , Andrew Halaney , Bean Huo , "Bao D. Nguyen" Subject: [PATCH v3 4/4] scsi: ufs: core: Always initialize the UIC done completion Date: Wed, 11 Sep 2024 17:30:49 -0700 Message-ID: <20240912003102.3110110-5-bvanassche@acm.org> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240912003102.3110110-1-bvanassche@acm.org> References: <20240912003102.3110110-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. Reviewed-by: Peter Wang 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 bd4ce3395972..753480a1c74e 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",