From patchwork Thu Oct 24 07:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13848481 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 2201E1AE863; Thu, 24 Oct 2024 07:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756370; cv=none; b=GJKq4Fgvik+kGuFVqKzJB4l7U+BLLCPqKwG+lV5T5elGBlBkIqPq4eyrwbmxLfJ+IYu+gkBQ8PBZseQneEJL4mqwToS78k4tV48x98Po342BQO6P3YlU4uW6S5/qsAaZuxBzazyn57X/6U5kDjODtTXo5z8U4elAmzAxi2xt7r0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756370; c=relaxed/simple; bh=NYjnmqabNKGDS/WLRXvLR7lqItwGdNIJsjD74Ocw3e8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=krMeIJNMJ620vOP0aixwht+HTVzqgjXuilZP8NXXenLBYtdZDrZXnPakqLjbLwD85MlZuhO1bEb/SPNmsh0WjHw+MBfzOfoSydmSP7shtykxzDVKbAxPRE0sh2740V8HitA5urgyv8BY6JEH9letZ6nE7plvGw3XrGe+xBHUZ7Q= 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=MWWsr1z8; arc=none smtp.client-ip=216.71.154.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="MWWsr1z8" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1729756368; x=1761292368; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NYjnmqabNKGDS/WLRXvLR7lqItwGdNIJsjD74Ocw3e8=; b=MWWsr1z8VUux7ZkAgechVPUlBr43Fqa2W1Dp5b96YgVn+VemdH8LmH/E yP1VIAsEjkawNtAiLxmuRBZrelT6SwmQoSNzkJVxHe+JNIokrjAxaB33W 1zVY/GhzgSi7lqamrO8NSKwFrHRqzo2XgLbxncScFyt2WJxoaFhmTnCBE RjyD4fw5emPW4XeMEEtGFeIfY35Tapy4v7jnYxK1t05wa+f++4/yAWDHf 2xfybHZqtDpUzzQoVGU8ZMqqUm1PzyFToYIEG2OBPgxDgjPLqWFX/sthb 00GK9vXc9bBLTgCeXBCHnG6XsISX/wUm92D9h8mq4mhAErydxGcDVRFuz g==; X-CSE-ConnectionGUID: GcAk89KQQUGd71H086u0MA== X-CSE-MsgGUID: AID6n5ueTd2t/m5VvLn0JA== X-IronPort-AV: E=Sophos;i="6.11,228,1725292800"; d="scan'208";a="29156102" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Oct 2024 15:52:43 +0800 IronPort-SDR: 6719ee59_k9Pn0fkzysnqzw1p7yvU0bCoadYhKBW0iIyIV+T63Ru7mCA SyZNHuARANUkVhzqIvwNvWKYWMD3S+9gDdT5/aQ== 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; 23 Oct 2024 23:51:05 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Oct 2024 00:52:42 -0700 From: Avri Altman To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Bart Van Assche , Avri Altman Subject: [PATCH v3 1/3] scsi: ufs: core: Remove redundant host_lock calls around UTMRLDBR. Date: Thu, 24 Oct 2024 10:50:31 +0300 Message-Id: <20241024075033.562562-2-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241024075033.562562-1-avri.altman@wdc.com> References: <20241024075033.562562-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no need to serialize single read/write calls to the host controller registers. Remove the redundant host_lock calls that protect access to the task management doorbell register: UTMRLDBR. Signed-off-by: Avri Altman Reviewed-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 9e6d008f4ea4..faea4b294bdb 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1245,11 +1245,13 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba, static u32 ufshcd_pending_cmds(struct ufs_hba *hba) { const struct scsi_device *sdev; + unsigned long flags; u32 pending = 0; - lockdep_assert_held(hba->host->host_lock); + spin_lock_irqsave(hba->host->host_lock, flags); __shost_for_each_device(sdev, hba->host) pending += sbitmap_weight(&sdev->budget_map); + spin_unlock_irqrestore(hba->host->host_lock, flags); return pending; } @@ -1263,7 +1265,6 @@ static u32 ufshcd_pending_cmds(struct ufs_hba *hba) static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us) { - unsigned long flags; int ret = 0; u32 tm_doorbell; u32 tr_pending; @@ -1271,7 +1272,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, ktime_t start; ufshcd_hold(hba); - spin_lock_irqsave(hba->host->host_lock, flags); /* * Wait for all the outstanding tasks/transfer requests. * Verify by checking the doorbell registers are clear. @@ -1292,7 +1292,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, break; } - spin_unlock_irqrestore(hba->host->host_lock, flags); io_schedule_timeout(msecs_to_jiffies(20)); if (ktime_to_us(ktime_sub(ktime_get(), start)) > wait_timeout_us) { @@ -1304,7 +1303,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, */ do_last_check = true; } - spin_lock_irqsave(hba->host->host_lock, flags); } while (tm_doorbell || tr_pending); if (timeout) { @@ -1314,7 +1312,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, ret = -EBUSY; } out: - spin_unlock_irqrestore(hba->host->host_lock, flags); ufshcd_release(hba); return ret; } @@ -7065,12 +7062,13 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq)); ufshcd_vops_setup_task_mgmt(hba, task_tag, tm_function); - /* send command to the controller */ __set_bit(task_tag, &hba->outstanding_tasks); - ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL); spin_unlock_irqrestore(host->host_lock, flags); + /* send command to the controller */ + ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL); + ufshcd_add_tm_upiu_trace(hba, task_tag, UFS_TM_SEND); /* wait until the task management command is completed */ From patchwork Thu Oct 24 07:50:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13848482 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 9F8191AF0D6; Thu, 24 Oct 2024 07:52:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756371; cv=none; b=XYAFO6rnvKrRiCDy/fSqw4oUspNqfdOjjjRE99i+fcrKuwHFdDcDr756TyjtTdpRs3Gp+P2Wdsj5e+fIWHvPgA1IdZeW+iEi3Zd2I55DOswoKdsKmmCV6swIlE3flsPLw5vUQllqSyGDsGIF2Yp2fXTwmQYnRZZUL6+JnA18J1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756371; c=relaxed/simple; bh=SRocwuixUYSgIE0bkZnSwSKBfeC4gykcO7qkFJlSgHY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DhvDZL2avsdRVz40mlT1P3A4xvqW+sS7pPLDGA30kfI65LxTSd4lX77rIAjLl26DOqeITLvKbvHEpo6dYxhsRTjoNb/n2lAZvD73K+XbWPkX/yV/OasSX/W+XMVNw0nmZBOSzvnjy9beuKuMAYlr1GgaPo2ncV/C0nqCx40dl4Y= 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=N0unCHey; arc=none smtp.client-ip=216.71.154.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="N0unCHey" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1729756369; x=1761292369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SRocwuixUYSgIE0bkZnSwSKBfeC4gykcO7qkFJlSgHY=; b=N0unCHeypRvW0D1tnOpAK7Ff39lkgGcRYdHTuFlWDVQcq6GBv5vd81Mv HZOOxyFJll/qe5sEaf70Rsp3bsmvrXN27vPypuWSVLyH2kcEdB1RHke6w vA5EOdPN5uF5I3+cWiit13qkACMhFm0cP8LYG7IxL74dZyW2ESvYmbPfp Zv5kUB4QfBKjNUJ1sziAWFOqqwq+hqa/RMsgeAiupooU7p1KSSQkgRODW duikuZEmOs/RlfMLBAqyWjfnpzO0Xr4cjnfSBp5Q1Ev86K5O0QqV/floC lZzDyIh03EkYPh3EghcYDIhTVy0oCjVmjUD59ToEMcWOR3sxDq30pS4W0 A==; X-CSE-ConnectionGUID: BX5U/cqZTH2ZzjciCj3SQA== X-CSE-MsgGUID: 64NfhDn5TYqyAewlIUyIrA== X-IronPort-AV: E=Sophos;i="6.11,228,1725292800"; d="scan'208";a="29156110" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Oct 2024 15:52:47 +0800 IronPort-SDR: 6719ee5d_gOVQGwvdr4ILfAuNXyu4ql/LhQkqTNwSxd34sOzI7+knNFl e6I1s9+DW0y8bKtEECs7VVKj2leVy8j3uuJvrXA== 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; 23 Oct 2024 23:51:09 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Oct 2024 00:52:45 -0700 From: Avri Altman To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Bart Van Assche , Avri Altman Subject: [PATCH v3 2/3] scsi: ufs: core: Remove redundant host_lock calls around UTMRLCLR Date: Thu, 24 Oct 2024 10:50:32 +0300 Message-Id: <20241024075033.562562-3-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241024075033.562562-1-avri.altman@wdc.com> References: <20241024075033.562562-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no need to serialize single read/write calls to the host controller registers. Remove the redundant host_lock calls that protect access to the task management request List cLear register: UTMRLCLR. Reviewed-by: Bart Van Assche Signed-off-by: Avri Altman --- drivers/ufs/core/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index faea4b294bdb..c2f44834062e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7012,14 +7012,11 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) { int err = 0; u32 mask = 1 << tag; - unsigned long flags; if (!test_bit(tag, &hba->outstanding_tasks)) goto out; - spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_utmrl_clear(hba, tag); - spin_unlock_irqrestore(hba->host->host_lock, flags); /* poll for max. 1 sec to clear door bell register by h/w */ err = ufshcd_wait_for_register(hba, From patchwork Thu Oct 24 07:50:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13848483 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 A1CD71B0F2F; Thu, 24 Oct 2024 07:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756373; cv=none; b=lv8011UuKCPi6d1KIDsMbeOKzSX89RGa0V1H2o03YL6JXo8NhsIoXPoyLCZZKvxrraSlVk6h9SCdy0+D5JTlJ/M0HJzkJkzZrYy4W+7jgmBqHFU7TJ9/v+ppkpwkf6MgNVQYOF7IDvmwWNHHG6VVNFC5q5y90YJBQjOejdzp6I0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729756373; c=relaxed/simple; bh=g7K9uanHsVcasrKeC/Dgo7ppPr+wFiIxH1t04wElT6Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SDOGkytMjk6k7b9+/6pvALcAcu7MuP9cljvld0QMgOp8oY+IQm9zvxmvNxKWaJdwOPRBtqOfKR24mVCgfpvRBK/O/MNIjo+n5vGiecXUm1RuR87y/ilQbIU2/XOzSRYJ9pZyTfovG6+yuj92/qn6eKd3QU3RjFbeL6+F2eZku4E= 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=NvlqQ6Bo; arc=none smtp.client-ip=216.71.154.42 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="NvlqQ6Bo" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1729756371; x=1761292371; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g7K9uanHsVcasrKeC/Dgo7ppPr+wFiIxH1t04wElT6Y=; b=NvlqQ6BoCNFMKzRuSZI++lFLxTDBMRhpWUR10dMaJzOTSoPFwwq9wpk1 +th+VoeDyaWSc8a7Hw7sSBio1mR6uvv9xVoTuNoBXtODKPxM3YUnW8Iac ukpUnj8SmSmWlFArFg20dyRlqcjHmY1zrBlljcBC/uuht6E/uLAzH73GM L0H3AYpZ7NoU0ZHDJIH5rfWH+N3Rq4svsJwG08rM+lb3ZNkhk0VzEoQF9 IZjgV1DJvpDQffjVyteEcYgmqdNMk/98ITHPwZKwU1BaHLtQCQsdper1p 0eSDceeGmtPKs8qEf9PVMw1CSs5rDS8es8kJrW0Fxz16QrijjepqQ8PdJ w==; X-CSE-ConnectionGUID: tcBMAQ6rTFieVJ/ymzWs/Q== X-CSE-MsgGUID: wc7P8TlzQYy0cZ8mRLAQ1g== X-IronPort-AV: E=Sophos;i="6.11,228,1725292800"; d="scan'208";a="29156120" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 24 Oct 2024 15:52:51 +0800 IronPort-SDR: 6719ee61_djwrYq02H8dM03cc8YiVmWJgQNhr+sBFfqYlAbRdCgjhz5c Pk6PP8OYEyyHkhWaAd22bzCTCnxF/jIP2laGv1Q== 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; 23 Oct 2024 23:51:13 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Oct 2024 00:52:49 -0700 From: Avri Altman To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Bart Van Assche , Avri Altman Subject: [PATCH v3 3/3] scsi: ufs: core: Remove redundant host_lock calls around UTRLCLR. Date: Thu, 24 Oct 2024 10:50:33 +0300 Message-Id: <20241024075033.562562-4-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241024075033.562562-1-avri.altman@wdc.com> References: <20241024075033.562562-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no need to serialize single read/write calls to the host controller registers. Remove the redundant host_lock calls that protect access to the request list cLear register: UTRLCLR. Reviewed-by: Bart Van Assche Signed-off-by: Avri Altman --- drivers/ufs/core/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index c2f44834062e..5eefdc02d62b 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3076,7 +3076,6 @@ bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd) static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) { u32 mask; - unsigned long flags; int err; if (hba->mcq_enabled) { @@ -3096,9 +3095,7 @@ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) mask = 1U << task_tag; /* clear outstanding transaction before retry */ - spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_utrl_clear(hba, mask); - spin_unlock_irqrestore(hba->host->host_lock, flags); /* * wait for h/w to clear corresponding bit in door-bell.