From patchwork Mon Jul 8 21:15:56 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: 13727039 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 63C564503B for ; Mon, 8 Jul 2024 21:17:38 +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=1720473459; cv=none; b=XVH78RAki8ewAWJ4rFfXWLBKD3UXYjmOVAlPbiY00SH9m2zQLYLxFAxfs7uYsaD/ovYkHpjVwuiPGHBsbYcmItF/75RFSinWirc63f0+B/1jftqr3nL47F5w7RemPL1VQJCEVfGdlS0hVoHeukkmhAZH2YcjC8w9do6eF/0a4Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473459; c=relaxed/simple; bh=BAsc5MLO+gwJmiwQcYML31t1QPduHNpHmT0E31XYwoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LUjAq33jp5gvx4t92j6N1aI+aqAQvXSn0LrzSpFug9AgGNuUY/Nw97N93OXDxeFQEIi01ZY5Ysi8RseCtw0xUYeoA3siWJmdflbuoQ5WiGQ4j9Li4jqbiqgLSfVixgpGOl9sqorwpQ5oXyciZpGo4GHpASgmLk7gj9aHu0LrE/4= 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=1/TJrdkk; 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="1/TJrdkk" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxm12FLnz6Cnk9T; Mon, 8 Jul 2024 21:17:37 +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=1720473453; x=1723065454; bh=d2wWr BfTigkQD5z/WfCBGOH20AyrfifTkBSPKGeJhzQ=; b=1/TJrdkkYM83gcEieYbeP LWAyEVIdcOmMALm2ssGackqcrsCRHHn8yTyvoksb/HdO9T7eYJpwQCqSZofZG0dE cb489Ukb06wqynlFjN/2ZmrmCxYXbb2JnOGPc0FaQUaAEk6igMd3y8bL4eiRi0RA F8rO97aO50DSVNIShjDJD+hrt4TxBGHW+RAE2p/TftUn/kf/CD3GVoF1hCNjGNKn D4tN3TeSvNalCijJnNv8IzJNvXfAIi2mABQAL206XhagRXy5xuFwMJKKb0SBWJxe 9mhzi2+kZz3cMC3QU65JwurIfbsvpFWrzVGvcsU7v8iLmS7dZnw7t+kn+5LoAVJa 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 KTIP1d4-nAdl; Mon, 8 Jul 2024 21:17:33 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxlv4MDFz6Cnk9N; Mon, 8 Jul 2024 21:17:31 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno Subject: [PATCH v5 01/10] scsi: ufs: Declare functions once Date: Mon, 8 Jul 2024 14:15:56 -0700 Message-ID: <20240708211716.2827751-2-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Several functions are declared in include/ufs/ufshcd.h and also in drivers/ufs/core/ufshcd-priv.h. Remove the duplicate declarations. Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd-priv.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f42d99ce5bf1..668748477e6e 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -66,14 +66,8 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, int ufshcd_mcq_init(struct ufs_hba *hba); int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba); int ufshcd_mcq_memory_alloc(struct ufs_hba *hba); -void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba); -void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds); -u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i); -void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i); struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, struct request *req); -unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba, - struct ufs_hw_queue *hwq); void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba, struct ufs_hw_queue *hwq); bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd); From patchwork Mon Jul 8 21:15:57 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: 13727042 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 87AF181211 for ; Mon, 8 Jul 2024 21:17:57 +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=1720473479; cv=none; b=p+NODtsnOvX2FatXCPNbZxK1yxALUevHIMTJdtXxw106ELrD69Txqbxn0d70W44e+yPqnuKKY709GJwdxY5jLiZcQH7XKTKGvffXfvqzEJrHazwJlx8gIhpIfgochxgFGS5WQtatR8tFdnqUPyYfbpp4pXGK146WVkTPAZSXHkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473479; c=relaxed/simple; bh=bYp8sPxCFd14jkxscCELBpvHXUwhIP1DAxR+UhOCfaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M5peYbiQq6sJjW79K7C4e9SvhPNJ58uBKEoY6KUPfVR5q9g606uYMEAjgeHzu+Koh9fE8mc9YaxPHCv4Y7GuWeqzA0NQj3MRX6i2mf9T7sa0uichlYbW7AZbDVWr8l16xyvE9Iu48I8YrjqvwJ8w7ygeGUfy/7TC/sV0VPLbQoo= 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=LCzSFtRo; 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="LCzSFtRo" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxmN6mJLz6Cnk9T; Mon, 8 Jul 2024 21:17:56 +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=1720473465; x=1723065466; bh=CRauL cviic4LNBpxkj7sAq2RFYHk2EAtTt/3r17BCy4=; b=LCzSFtRoj8zAK2ahoik/S Qkz+k3IoC19vq8oTCLhA4Ej807Abv8LqC0neHqrajBm9ZHuPxUs8yV/TBFxKqjPV cMx498PHKjwL7ipI/Ju5fjIIeMbO/XVk0GWd7+anoYSTL4bLq84rxAKSbOj+u4Oh ljNhlhqFBMTQzLStSwpnMA0vq/3GmKs0DMe+pEo3p1kQ2A3xSVivVHPM9Ws/maPt tEQdSL/CxyZK3eY3BfxzSruYusyT99yQKGh9UcvvvBPk3sesDhsmVinvTfkVfXt8 DO71prugft7g3AooG8euB7TlEt7ewbFIa2QroCYBtp3IY/HguZgLPM6uK8+At6Yl 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 9NdCxG9m5Ofa; Mon, 8 Jul 2024 21:17:45 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxm55MD7z6Cnk9N; Mon, 8 Jul 2024 21:17:41 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , Daejun Park , Avri Altman , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Bean Huo , Minwoo Im , Maramaina Naresh , Akinobu Mita Subject: [PATCH v5 02/10] scsi: ufs: Initialize struct uic_command once Date: Mon, 8 Jul 2024 14:15:57 -0700 Message-ID: <20240708211716.2827751-3-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of first zero-initializing struct uic_command and next initializing it memberwise, initialize all members at once. Reviewed-by: Daejun Park Reviewed-by: Avri Altman Reviewed-by: Manivannan Sadhasivam Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 61 ++++++++++++++++++++------------------- include/ufs/ufshcd.h | 4 +-- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 98cc245b5576..13c57bbcdad7 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3994,11 +3994,11 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba) */ static int ufshcd_dme_link_startup(struct ufs_hba *hba) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_LINK_STARTUP, + }; int ret; - uic_cmd.command = UIC_CMD_DME_LINK_STARTUP; - ret = ufshcd_send_uic_cmd(hba, &uic_cmd); if (ret) dev_dbg(hba->dev, @@ -4016,11 +4016,11 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba) */ static int ufshcd_dme_reset(struct ufs_hba *hba) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_RESET, + }; int ret; - uic_cmd.command = UIC_CMD_DME_RESET; - ret = ufshcd_send_uic_cmd(hba, &uic_cmd); if (ret) dev_err(hba->dev, @@ -4055,11 +4055,11 @@ EXPORT_SYMBOL_GPL(ufshcd_dme_configure_adapt); */ static int ufshcd_dme_enable(struct ufs_hba *hba) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_ENABLE, + }; int ret; - uic_cmd.command = UIC_CMD_DME_ENABLE; - ret = ufshcd_send_uic_cmd(hba, &uic_cmd); if (ret) dev_err(hba->dev, @@ -4112,7 +4112,12 @@ static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba) int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel, u8 attr_set, u32 mib_val, u8 peer) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = peer ? UIC_CMD_DME_PEER_SET : UIC_CMD_DME_SET, + .argument1 = attr_sel, + .argument2 = UIC_ARG_ATTR_TYPE(attr_set), + .argument3 = mib_val, + }; static const char *const action[] = { "dme-set", "dme-peer-set" @@ -4121,12 +4126,6 @@ int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel, int ret; int retries = UFS_UIC_COMMAND_RETRIES; - uic_cmd.command = peer ? - UIC_CMD_DME_PEER_SET : UIC_CMD_DME_SET; - uic_cmd.argument1 = attr_sel; - uic_cmd.argument2 = UIC_ARG_ATTR_TYPE(attr_set); - uic_cmd.argument3 = mib_val; - do { /* for peer attributes we retry upon failure */ ret = ufshcd_send_uic_cmd(hba, &uic_cmd); @@ -4156,7 +4155,10 @@ EXPORT_SYMBOL_GPL(ufshcd_dme_set_attr); int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, u32 *mib_val, u8 peer) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = peer ? UIC_CMD_DME_PEER_GET : UIC_CMD_DME_GET, + .argument1 = attr_sel, + }; static const char *const action[] = { "dme-get", "dme-peer-get" @@ -4190,10 +4192,6 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, } } - uic_cmd.command = peer ? - UIC_CMD_DME_PEER_GET : UIC_CMD_DME_GET; - uic_cmd.argument1 = attr_sel; - do { /* for peer attributes we retry upon failure */ ret = ufshcd_send_uic_cmd(hba, &uic_cmd); @@ -4326,7 +4324,11 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) */ int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_SET, + .argument1 = UIC_ARG_MIB(PA_PWRMODE), + .argument3 = mode, + }; int ret; if (hba->quirks & UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP) { @@ -4339,9 +4341,6 @@ int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode) } } - uic_cmd.command = UIC_CMD_DME_SET; - uic_cmd.argument1 = UIC_ARG_MIB(PA_PWRMODE); - uic_cmd.argument3 = mode; ufshcd_hold(hba); ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd); ufshcd_release(hba); @@ -4382,13 +4381,14 @@ EXPORT_SYMBOL_GPL(ufshcd_link_recovery); int ufshcd_uic_hibern8_enter(struct ufs_hba *hba) { - int ret; - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_HIBER_ENTER, + }; ktime_t start = ktime_get(); + int ret; ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, PRE_CHANGE); - uic_cmd.command = UIC_CMD_DME_HIBER_ENTER; ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd); trace_ufshcd_profile_hibern8(dev_name(hba->dev), "enter", ktime_to_us(ktime_sub(ktime_get(), start)), ret); @@ -4406,13 +4406,14 @@ EXPORT_SYMBOL_GPL(ufshcd_uic_hibern8_enter); int ufshcd_uic_hibern8_exit(struct ufs_hba *hba) { - struct uic_command uic_cmd = {0}; + struct uic_command uic_cmd = { + .command = UIC_CMD_DME_HIBER_EXIT, + }; int ret; ktime_t start = ktime_get(); ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, PRE_CHANGE); - uic_cmd.command = UIC_CMD_DME_HIBER_EXIT; ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd); trace_ufshcd_profile_hibern8(dev_name(hba->dev), "exit", ktime_to_us(ktime_sub(ktime_get(), start)), ret); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 049520bcc6c0..42d1bd2120ea 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -73,8 +73,8 @@ enum ufs_event_type { * @done: UIC command completion */ struct uic_command { - u32 command; - u32 argument1; + const u32 command; + const u32 argument1; u32 argument2; u32 argument3; int cmd_active; From patchwork Mon Jul 8 21:15:58 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: 13727041 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 1718D4503B for ; Mon, 8 Jul 2024 21:17:56 +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=1720473478; cv=none; b=iJYA6rVPnZUTQMB5S+ZdonapYLF1rXyizeVAEtMWM1YDpyE1Eby40u9kKHcixZgWK3r5UCAtTcSvMpHBLfncymBSc0tk+YmoYd3Wkp14YImVg9+NKtIgLkl02gt4yGn78z9HRXE9/X2gykyKtVUXdM2Eg/ZDd5aUwJh9US4SaHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473478; c=relaxed/simple; bh=bog69wK+u3MJRMP5GkrTiQEfg3DlANbSlM5Tbw4Sz1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QYm9e1ynXDO5qG8jJ6l5RBiAxG9reEOA5EQT1c12rDjx+JH526uWm9AAzb2gF6tqp9BuwrVpyhZasGhq7OrDfrSjuT85LKSVdZzSSfDR14ByJbHMcoATktZtSEdih1hbzeg9mqaKd6mqUX0mdhsvmW7ECzP1mkL7PIMqMNJB4lU= 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=gZeeJj0b; 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="gZeeJj0b" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxmN3rmbz6CmM6L; Mon, 8 Jul 2024 21:17:56 +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=1720473472; x=1723065473; bh=7zR3X MkbbD1SWPzGr1k7aZOsIkLMqYr2141aP0Wn/qU=; b=gZeeJj0bP9AigoUflvaEZ hDq7S7j12cMCXrxew6zZlmPFs+a5zec4KIf6XP/PWZcT65JK2IH6rMgyoDHql9Uz k9tTbQzPypMk11uUardV+/4c80nlWCMnEGv4JUVBhmWcsKZ/AKhjX2b9cTGABZO0 f7nzrB74HEWG2HSjxUsmelUEoDZxkfn1SrKYk+UGDIWNUwmchwgVHvC8FziPQQdW OpgWqR5r2nwWj6JMSX2rGA7pWxSB9MCPaf9pLG7dvTe9naJ7FAhi55mL4cCXzISM W0xnesnQcCSeNcKb7VZfswaPEy/O3eup0CSvCmrD1hC8DaWXBj0JAOlwNjKs13b+ 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 7JakenHeNeXW; Mon, 8 Jul 2024 21:17:52 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxmF3Qbzz6Cnk9T; Mon, 8 Jul 2024 21:17:49 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , Keoseong Park , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Bean Huo Subject: [PATCH v5 03/10] scsi: ufs: Remove two constants Date: Mon, 8 Jul 2024 14:15:58 -0700 Message-ID: <20240708211716.2827751-4-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The SCSI host template members .cmd_per_lun and .can_queue are copied into the SCSI host data structure. Before these are used, these are overwritten by ufshcd_init(). Hence, this patch does not change any functionality. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Keoseong Park Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 13c57bbcdad7..1b0445bb5b7a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -164,8 +164,6 @@ EXPORT_SYMBOL_GPL(ufshcd_dump_regs); enum { UFSHCD_MAX_CHANNEL = 0, UFSHCD_MAX_ID = 1, - UFSHCD_CMD_PER_LUN = 32 - UFSHCD_NUM_RESERVED, - UFSHCD_CAN_QUEUE = 32 - UFSHCD_NUM_RESERVED, }; static const char *const ufshcd_state_name[] = { @@ -8959,8 +8957,6 @@ static const struct scsi_host_template ufshcd_driver_template = { .eh_timed_out = ufshcd_eh_timed_out, .this_id = -1, .sg_tablesize = SG_ALL, - .cmd_per_lun = UFSHCD_CMD_PER_LUN, - .can_queue = UFSHCD_CAN_QUEUE, .max_segment_size = PRDT_DATA_BYTE_COUNT_MAX, .max_sectors = SZ_1M / SECTOR_SIZE, .max_host_blocked = 1, From patchwork Mon Jul 8 21:15:59 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: 13727043 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 701E14503B for ; Mon, 8 Jul 2024 21:18:07 +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=1720473488; cv=none; b=AmLdpM1tc69KoboNTFSLDIMQ1P7UF02cBLyZMhhl9iU9zErFe4KRDzqSw40fp7KoBBDAVMTL+IEmFrwoALs2qGYEWiKyfA0V+zwwrnC1JERJDCTZj2cwQmt66yeURrq3xynLZ3uJIDDBwAZG7CtPYof0EMgtYul0Y3lS7Nod56M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473488; c=relaxed/simple; bh=wgFC41ALw28xbVLTqP+3Kg96PRcWR4GWO7lu3O1t9TE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iGFHu4hEdeYEcAuwvcx9BdTAjtYLs7vNxm04JTNuZRCYY+jFAkRK3VsSHXUH7/T24nBcFTo0LAmjs2SJ5JWHcP7NTADtA9cokVGU6ys3GuXlmXleFQLYxDIb4G8C9lJF8ToFZ63ib3CtRN4vQNKY1f34q9suOKon2rTYfEqWAXs= 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=bHnozcGY; 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="bHnozcGY" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxmZ6hGxz6CmM6L; Mon, 8 Jul 2024 21:18:06 +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=1720473482; x=1723065483; bh=RoWIf 25Y+Ayp3le60uhgK98EibE0ad3TzuWPjx1Up8U=; b=bHnozcGYSR2tTXFIkJH/Q eC7La8qSd/CWQlpmdtqonKB5h/p2adlQlPK6cSO/yDXS4gswSxZHJF5DGvLcHJya P2ge3Rr5k3LQrRBxPk1CEueINZbuCKvi5znCQOhSxHMEUjfTtlOOW85gkeSbUkQT Qvnnule7LhNUeOHEyXwsEDSmZ0M1bLs6QSmJyqpJU07yI7y3Ort1yslchnCQ7NBM t1noT3wOp6vhjCGQSUKtH0JQ3XOLFjjX3UBcc85aAphwniLz24Jl3ZuMx9m4SyRn eAxSkdjykQMMpzLL68ZVFkfFJDQTGHZAN7RC+7sV6pnUZBK0/pNMQhZGbMig78uu 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 U0Fy_TPs1eDl; Mon, 8 Jul 2024 21:18:02 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxmR4sBYz6Cnk9N; Mon, 8 Jul 2024 21:17:59 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Bean Huo , ChanWoo Lee Subject: [PATCH v5 04/10] scsi: ufs: Rename the MASK_TRANSFER_REQUESTS_SLOTS constant Date: Mon, 8 Jul 2024 14:15:59 -0700 Message-ID: <20240708211716.2827751-5-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename this constant to prepare for the introduction of the MASK_TRANSFER_REQUESTS_SLOTS_MCQ constant. The acronym "SDB" stands for "single doorbell" (mode). Reviewed-by: Peter Wang Reviewed-by: Manivannan Sadhasivam Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 2 +- include/ufs/ufshci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 1b0445bb5b7a..a7b049deb943 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2402,7 +2402,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT; /* nutrs and nutmrs are 0 based values */ - hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS) + 1; + hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS_SDB) + 1; hba->nutmrs = ((hba->capabilities & MASK_TASK_MANAGEMENT_REQUEST_SLOTS) >> 16) + 1; hba->reserved_slot = hba->nutrs - 1; diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h index c50f92bf2e1d..8d0cc73537c6 100644 --- a/include/ufs/ufshci.h +++ b/include/ufs/ufshci.h @@ -67,7 +67,7 @@ enum { /* Controller capability masks */ enum { - MASK_TRANSFER_REQUESTS_SLOTS = 0x0000001F, + MASK_TRANSFER_REQUESTS_SLOTS_SDB = 0x0000001F, MASK_NUMBER_OUTSTANDING_RTT = 0x0000FF00, MASK_TASK_MANAGEMENT_REQUEST_SLOTS = 0x00070000, MASK_EHSLUTRD_SUPPORTED = 0x00400000, From patchwork Mon Jul 8 21:16:00 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: 13727044 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 1F4BD4503B for ; Mon, 8 Jul 2024 21:18:15 +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=1720473496; cv=none; b=EIbORQO51Jc0PXoukKbUrfzen/cGf7OG9Gu2Z84UmOVSHYKrKRJe+nA8ExHrkAVWFt479n3N+xB5jYdEb9yTz3/LFuILctltoVs7k58bRHr4US73DMuQvPKIhFBmYH6uXDPEKLbb7P76YpalM3tbniwjUFvJRw0S5LD/5jjLYT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473496; c=relaxed/simple; bh=gtmE3v4LVy2tHbV7shbnCLMD1Mhd/9BW6tDikGCf2nM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tenDyE3Nml+p9g9cmzRmAeZq/sdZXe77I8rUfMdC21yliNaCgR2FCdnIqwJcLqxkbzRdr4z3Q+LICY4EcY/MdDWnzo9P9ZxEyeJLdKClHojr77zg3QxDG0yUh1DIlefacSVw+xuRfEyHbdMzoT4vBUUNPEMYgFsqOEDvAPg8jLs= 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=QfyucIGl; 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="QfyucIGl" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxmk68yTz6Cnk9F; Mon, 8 Jul 2024 21:18:14 +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=1720473489; x=1723065490; bh=SSR+E nRThIzEVjXzicOgiaGD8AlNTBsrjQKjmKQkk9M=; b=QfyucIGlr/MxLDVaus3L0 yfvy8cftCwleQx5FjqW5tt5sz8hu/4TZDCgP1wO4wNQtmd3TfdEmHoKhE1snkvc8 YGTdhIi+1HW0mDWvAoBlf/Hp/o6hWXkjT186M/9pi0rra37swxh30hbmI+VKBCRr sGIQLhdng9xLWFQAyHX7zTiNEywqKmSoLc/iZg3k+WVX/3IDJphIbysyGAJTRooS +9JMTO58cA1KFWeP4uMyVZZGJYz92+fLzwAHQ4JQ5CTOeZaIKw+iMbjF2loYWm7t XNAik8C32rTz7IxRedtNWrz+JqEs0znfHf7ORM+29LdQuSbamMXwqvy4sWRF0Lwh 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 NzaXH_lct6nL; Mon, 8 Jul 2024 21:18:09 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxmZ5FvVz6Cnk9T; Mon, 8 Jul 2024 21:18:06 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , Can Guo , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v5 05/10] scsi: ufs: Initialize hba->reserved_slot earlier Date: Mon, 8 Jul 2024 14:16:00 -0700 Message-ID: <20240708211716.2827751-6-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the hba->reserved_slot and the host->can_queue assignments from ufshcd_config_mcq() into ufshcd_alloc_mcq(). The advantages of this change are as follows: - It becomes easier to verify that these two parameters are updated if hba->nutrs is updated. - It prevents unnecessary assignments to these two parameters. While ufshcd_config_mcq() is called during host reset, ufshcd_alloc_mcq() is not. Cc: Can Guo Reviewed-by: Peter Wang Reviewed-by: Manivannan Sadhasivam Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index a7b049deb943..3d452aa923dc 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8679,6 +8679,9 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba) if (ret) goto err; + hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; + hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED; + return 0; err: hba->nutrs = old_nutrs; @@ -8700,9 +8703,6 @@ static void ufshcd_config_mcq(struct ufs_hba *hba) ufshcd_mcq_make_queues_operational(hba); ufshcd_mcq_config_mac(hba, hba->nutrs); - hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; - hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED; - ufshcd_mcq_enable(hba); hba->mcq_enabled = true; From patchwork Mon Jul 8 21:16:01 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: 13727045 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 5EC4A81211 for ; Mon, 8 Jul 2024 21:18:33 +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=1720473515; cv=none; b=jOwcHiIiCZK1opJiGry8FHXYMjTGLrN2QyN6eu5n9nRvsBrZDAECyojdcPZTDVVfGqJMdurNh8zw5cvKANNfW9kb+4twxsfLgjAcEiV3tTdKboJLYSXtnM8HehsxHYC8QVdsmOOnW7EfRHU0usQYrn3wfFmVbDEV+eyF2kZ6tAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473515; c=relaxed/simple; bh=0LuI8WurHhvuYxkRi4pG8BCetfbuz27YPnjyZP14CdY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UD/HtGqLgAkH9KvN3ixYO75uq+zC2dM6N7Fu8CkgLfRx7Y/lURjr9tIISzJ5JvtCFcrBm4VqsF2MGvUd96oMQK1Hd0JatKdTR6DGV5ilZYqCTyDfisGOpDYiNKgXONqBP1XH2R/+gZk3WPNo+Br/kVEUXe4xilxhnJ/r5ZSbCls= 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=LAxMeXcE; 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="LAxMeXcE" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxn46TCnz6CmR43; Mon, 8 Jul 2024 21:18:32 +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=1720473500; x=1723065501; bh=RIkkv v10Amm/+cM8OJCBkci6GHjFHsVwAn+832ErxtY=; b=LAxMeXcEC08jJdw+ZUJDb Op1HM+pNXUtAJWj6zQpmsD/UPzMOi7GzCvfEJZBvvdOp7pNtBy289bOLl3AubQfm ZWjPst8oQjIkamp2Z37tESBmPwaE1IpUdslHYuL2dDdycWy33De5savVXptfXdap wbsSrnt9cFXJnclMMBCQ2HODjKt6vuDwvi8a9uYQfy5GWkdGbvMCvdse+uV52IZa YG6SZNaW7XCg6Ck38/HhLTi2fT7+PrOhjDm8UeAewKJiI+i/Bl4oUysso4lRHvE+ geuLUzIj9gXBh0Ps6mWdb/Q53mQtTDOlIxvZeeBB+DzFmYvBaQYhWsi7LBktk8rK 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 8hbpVd64T0HG; Mon, 8 Jul 2024 21:18:20 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxmn2Hb0z6Cnk9N; Mon, 8 Jul 2024 21:18:17 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Bean Huo , Minwoo Im , Maramaina Naresh , Akinobu Mita Subject: [PATCH v5 06/10] scsi: ufs: Inline is_mcq_enabled() Date: Mon, 8 Jul 2024 14:16:01 -0700 Message-ID: <20240708211716.2827751-7-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Improve code readability by inlining is_mcq_enabled(). Cc: Peter Wang Cc: Manivannan Sadhasivam Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 28 ++++++++++++++-------------- drivers/ufs/host/ufs-mediatek.c | 6 +++--- include/ufs/ufshcd.h | 5 ----- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 3d452aa923dc..255d55e15b73 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -453,7 +453,7 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, intr = ufshcd_readl(hba, REG_INTERRUPT_STATUS); - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq); hwq_id = hwq->id; @@ -2302,7 +2302,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) ufshcd_start_monitor(hba, lrbp); - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { int utrd_size = sizeof(struct utp_transfer_req_desc); struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr; struct utp_transfer_req_desc *dest; @@ -3001,7 +3001,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) goto out; } - if (is_mcq_enabled(hba)) + if (hba->mcq_enabled) hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); ufshcd_send_command(hba, tag, hwq); @@ -3060,7 +3060,7 @@ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) unsigned long flags; int err; - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { /* * MCQ mode. Clean up the MCQ resources similar to * what the ufshcd_utrl_clear() does for SDB mode. @@ -3170,7 +3170,7 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, __func__, lrbp->task_tag); /* MCQ mode */ - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { /* successfully cleared the command, retry if needed */ if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) err = -EAGAIN; @@ -5561,7 +5561,7 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num) u32 tr_doorbell; struct ufs_hw_queue *hwq; - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { hwq = &hba->uhq[queue_num]; return ufshcd_mcq_poll_cqe_lock(hba, hwq); @@ -6202,7 +6202,7 @@ static void ufshcd_exception_event_handler(struct work_struct *work) /* Complete requests that have door-bell cleared */ static void ufshcd_complete_requests(struct ufs_hba *hba, bool force_compl) { - if (is_mcq_enabled(hba)) + if (hba->mcq_enabled) ufshcd_mcq_compl_pending_transfer(hba, force_compl); else ufshcd_transfer_req_compl(hba); @@ -6459,7 +6459,7 @@ static bool ufshcd_abort_one(struct request *rq, void *priv) *ret ? "failed" : "succeeded"); /* Release cmd in MCQ mode if abort succeeds */ - if (is_mcq_enabled(hba) && (*ret == 0)) { + if (hba->mcq_enabled && (*ret == 0)) { hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(lrbp->cmd)); spin_lock_irqsave(&hwq->cq_lock, flags); if (ufshcd_cmd_inflight(lrbp->cmd)) @@ -7390,7 +7390,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) goto out; } - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { for (pos = 0; pos < hba->nutrs; pos++) { lrbp = &hba->lrb[pos]; if (ufshcd_cmd_inflight(lrbp->cmd) && @@ -7486,7 +7486,7 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag) */ dev_err(hba->dev, "%s: cmd at tag %d not pending in the device.\n", __func__, tag); - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { /* MCQ mode */ if (ufshcd_cmd_inflight(lrbp->cmd)) { /* sleep for max. 200us same delay as in SDB mode */ @@ -7564,7 +7564,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) ufshcd_hold(hba); - if (!is_mcq_enabled(hba)) { + if (!hba->mcq_enabled) { reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); if (!test_bit(tag, &hba->outstanding_reqs)) { /* If command is already aborted/completed, return FAILED. */ @@ -7597,7 +7597,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) } hba->req_abort_count++; - if (!is_mcq_enabled(hba) && !(reg & (1 << tag))) { + if (!hba->mcq_enabled && !(reg & (1 << tag))) { /* only execute this code in single doorbell mode */ dev_err(hba->dev, "%s: cmd was completed, but without a notifying intr, tag = %d", @@ -7624,7 +7624,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { /* MCQ mode. Branch off to handle abort for mcq mode */ err = ufshcd_mcq_abort(cmd); goto release; @@ -8733,7 +8733,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) ufshcd_set_link_active(hba); /* Reconfigure MCQ upon reset */ - if (is_mcq_enabled(hba) && !init_dev_params) + if (hba->mcq_enabled && !init_dev_params) ufshcd_config_mcq(hba); /* Verify device initialization by sending NOP OUT UPIU */ diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index c7a0ab9b1f59..02c9064284e1 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -693,7 +693,7 @@ static void ufs_mtk_mcq_disable_irq(struct ufs_hba *hba) struct ufs_mtk_host *host = ufshcd_get_variant(hba); u32 irq, i; - if (!is_mcq_enabled(hba)) + if (!hba->mcq_enabled) return; if (host->mcq_nr_intr == 0) @@ -711,7 +711,7 @@ static void ufs_mtk_mcq_enable_irq(struct ufs_hba *hba) struct ufs_mtk_host *host = ufshcd_get_variant(hba); u32 irq, i; - if (!is_mcq_enabled(hba)) + if (!hba->mcq_enabled) return; if (host->mcq_nr_intr == 0) @@ -1308,7 +1308,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) if (err) return err; - if (is_mcq_enabled(hba)) { + if (hba->mcq_enabled) { ufs_mtk_config_mcq(hba, false); ufshcd_mcq_make_queues_operational(hba); ufshcd_mcq_config_mac(hba, hba->nutrs); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 42d1bd2120ea..3eaa8bc7eaea 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1133,11 +1133,6 @@ struct ufs_hw_queue { #define MCQ_QCFG_SIZE 0x40 -static inline bool is_mcq_enabled(struct ufs_hba *hba) -{ - return hba->mcq_enabled; -} - static inline unsigned int ufshcd_mcq_opr_offset(struct ufs_hba *hba, enum ufshcd_mcq_opr opr, int idx) { From patchwork Mon Jul 8 21:16:02 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: 13727046 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 3166A81211 for ; Mon, 8 Jul 2024 21:18:36 +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=1720473518; cv=none; b=W4cDSC5CqM/3Y80WAIOISgfNUev9LBemUCu/EdkWV0gXm+WA3XwSiR7YInM2Ig/9ZJNHiNiiQRS9QmkpH/X7OQN3Oyug3SJy1+x/xfAB0t8gbNww7fMN1N7SrFjxV+FOyVDczPqCJOoYQp33X7BW0wSJPnBQSVkpPLaTm07iUus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473518; c=relaxed/simple; bh=/aZuJV20TQQnd4ghsTL1DGrgmHNMQXLzHv9ubuf7Amg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o32nBhQR+ctG6fR6QIfcmo5CGQkF6YBMwhtDdkwnIXGdk8VDSrur33X1T11Y6b+30TgVjuCNFu0LLXvq1lE2RXFlESwX5McX21WJkCcx+IlO7vgmNb3nA5AA/famMUOcoaX13f7xt4AxOgs0lCSAEpyEbWaRC4Qv7QqASkGQJj4= 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=WKIQbMse; 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="WKIQbMse" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxn854H9z6CmM6L; Mon, 8 Jul 2024 21:18:36 +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=1720473511; x=1723065512; bh=EAn82 yBWlBDiTm0fHJPVfVFUzHL84kiW/YkX8khFB2o=; b=WKIQbMsem+j1VIN9dgyI6 7ZuLM1o8/5pnZIwsYy/D8pJI1GXbJ6xOkHG4OOMcA9inGdJcPClV8RxlP2OgBEhd ZBd8DoBloVP3AglFEZFFT2sIYboMXtXKeO6LMX8HJMiqr8d6jQs9cf+fVGG+SBWA 5X8XUDv9RA9nWd7qgooTyskRGGGf9RsNuYFFqeWpnOXxpPMQZF0t/f4sL0J0u4yK vk7FDugUsnqvp1qR7WIm24dmzTriLeofNozneqA3C19m1A/KTl86a4wqKaJ69Uz4 kfK88GtEuZuqx6U7ZX5HWeDk23MZxE51wbIFqgv4vpeSfMONsxR0jD3vMRhEqYaV 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 ak3RzXoeYZAX; Mon, 8 Jul 2024 21:18:31 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxn03Y3Bz6Cnk9V; Mon, 8 Jul 2024 21:18:28 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Minwoo Im , ChanWoo Lee , Rohit Ner , Naomi Chu , Yang Li , Avri Altman , Bean Huo Subject: [PATCH v5 07/10] scsi: ufs: Move the "hba->mcq_enabled = true" assignment Date: Mon, 8 Jul 2024 14:16:02 -0700 Message-ID: <20240708211716.2827751-8-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the "hba->mcq_enabled = true" assignment to prevent that it gets duplicated by a later patch that will introduce more ufshcd_mcq_enable() calls. No functionality is changed by this patch. Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Peter Wang --- drivers/ufs/core/ufs-mcq.c | 1 + drivers/ufs/core/ufshcd.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 4bcae410c268..0a9597a6d059 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -416,6 +416,7 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_enable_esi); void ufshcd_mcq_enable(struct ufs_hba *hba) { ufshcd_rmwl(hba, MCQ_MODE_SELECT, MCQ_MODE_SELECT, REG_UFS_MEM_CFG); + hba->mcq_enabled = true; } EXPORT_SYMBOL_GPL(ufshcd_mcq_enable); diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 255d55e15b73..7647d8969001 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8704,7 +8704,6 @@ static void ufshcd_config_mcq(struct ufs_hba *hba) ufshcd_mcq_config_mac(hba, hba->nutrs); ufshcd_mcq_enable(hba); - hba->mcq_enabled = true; dev_info(hba->dev, "MCQ configured, nr_queues=%d, io_queues=%d, read_queue=%d, poll_queues=%d, queue_depth=%d\n", hba->nr_hw_queues, hba->nr_queues[HCTX_TYPE_DEFAULT], From patchwork Mon Jul 8 21:16:03 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: 13727047 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 16EDE4503B for ; Mon, 8 Jul 2024 21:18:44 +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=1720473525; cv=none; b=mGSL3JVQp8vP0X1YIyhfdNL0obf/IBM6slDiDIOj1uwdKCr5S+5sYpE7RFKZgHCL5qHq1fyhx7qHrZ9l+ixugoWRaa7m/j3GQF9Uo8YQv93XVCJnhTbDX+gUus8CtkRghPc0pboewZlNyYbTPnxqNNOI2ePO5iVT4LMIM1L9Cbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473525; c=relaxed/simple; bh=OF0AYM3jXojWz985L+ExGFni52V4rVaRVWAUJCFKAio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XYFIZ0PCCEUaBpiWsCdOZfo+YIG53RJNnT3JiyGScCvH9n5k8Sr3dEo+SZu6k8a7cyVf8F91qyNxf6kvq+uu/sapdC6n2KuAW89RBJvQngfe/eZi79f8QPzrEZv1ghWH7RelVhBDXPs/4k6l6pNH7QCWWzbga3svS800wYUrJgs= 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=i6beVi0s; 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="i6beVi0s" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxnH5tqVz6Cnk9V; Mon, 8 Jul 2024 21:18:43 +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=1720473518; x=1723065519; bh=OREPE 0UDeIjHWoZ7VAogE56R5+JeeizDDmjIl8AEMWI=; b=i6beVi0s7ZKzyE6h+FI+t lNmSb4OStnnZyjRcLbLgmttK0cbFXSsuYZhlMWsmwvPLxSGktZTX2HoAY5IQ1IVb Gtpa28TOCxrBBu/tS/Zju0QHn1GWrHYu+FRAo1v/b/j8n0dR7Nma0xQBovlN2toF lLZk+HB9lfeevt59fVvPuC6mHq3ZupVneZ1iJyQpdDFjgU9AEABitPtnVC//8w6N TM7zuYlFBPDpoW8C6RN6pImTVPH7GPKnZm7OFM9lrZr2n4MsR5smOb6qlFT6Vyf3 mbDXAGb30fLF22X+iNKUFsnKNMoLM/q4XRVuUwu39VTeuAyd0neLZlG2KeZbyB1I 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 i-4EqqT7W4E9; Mon, 8 Jul 2024 21:18:38 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxn773Q1z6CmR43; Mon, 8 Jul 2024 21:18:35 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v5 08/10] scsi: ufs: Move the ufshcd_mcq_enable() call Date: Mon, 8 Jul 2024 14:16:03 -0700 Message-ID: <20240708211716.2827751-9-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the ufshcd_mcq_enable() call from inside ufshcd_config_mcq() to the callers of this function. No functionality is changed by this patch. This patch makes a later patch easier to read ("scsi: ufs: Make .get_hba_mac() optional"). Cc: Peter Wang Cc: Manivannan Sadhasivam Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7647d8969001..4c2b60dec43f 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8703,8 +8703,6 @@ static void ufshcd_config_mcq(struct ufs_hba *hba) ufshcd_mcq_make_queues_operational(hba); ufshcd_mcq_config_mac(hba, hba->nutrs); - ufshcd_mcq_enable(hba); - dev_info(hba->dev, "MCQ configured, nr_queues=%d, io_queues=%d, read_queue=%d, poll_queues=%d, queue_depth=%d\n", hba->nr_hw_queues, hba->nr_queues[HCTX_TYPE_DEFAULT], hba->nr_queues[HCTX_TYPE_READ], hba->nr_queues[HCTX_TYPE_POLL], @@ -8732,8 +8730,10 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) ufshcd_set_link_active(hba); /* Reconfigure MCQ upon reset */ - if (hba->mcq_enabled && !init_dev_params) + if (hba->mcq_enabled && !init_dev_params) { ufshcd_config_mcq(hba); + ufshcd_mcq_enable(hba); + } /* Verify device initialization by sending NOP OUT UPIU */ ret = ufshcd_verify_dev_init(hba); @@ -8757,6 +8757,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) ret = ufshcd_alloc_mcq(hba); if (!ret) { ufshcd_config_mcq(hba); + ufshcd_mcq_enable(hba); } else { /* Continue with SDB mode */ use_mcq_mode = false; @@ -8772,6 +8773,7 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) } else if (is_mcq_supported(hba)) { /* UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH is set */ ufshcd_config_mcq(hba); + ufshcd_mcq_enable(hba); } } From patchwork Mon Jul 8 21:16:04 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: 13727048 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 C051D14F117 for ; Mon, 8 Jul 2024 21:18:56 +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=1720473538; cv=none; b=YFiWxOnnC0tm84O3ZOPEZW9Q0go4Se/BZTd4IjdrXhnS0geywTBoo1u4REZ/MF+AEf2mY8b+MSyyydPt4TwWQMIC8PdFU4RTRBuulLww6vjArpbk+EKgkF8sTNonvS0ZKvPow0MF46B0Cbi0wWj+aTwBhEzc9yp85L5djaVGB70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473538; c=relaxed/simple; bh=25ONgGd/9OKImgCd/A6nWe/9/CLMIUNh8u51HbmpPxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pXfZqG8/jRaPYfYpmbySUY9DrXUgsE1JwFcOFueq0foDRIZwTQhBkx0KVWuJKeJESd2Zb5XBnHGfBE69jg2gJmPgfPS8GV4AbedhqZ9gUpMYsOeqO/ojPXkfk+2wqXs/+1olp0PLoseKnek8ZjM3VpyvcLPc3kv6pVyQhcpQQtY= 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=XsAI4yq4; 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="XsAI4yq4" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxnX3qVVz6CmR43; Mon, 8 Jul 2024 21:18:56 +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=1720473529; x=1723065530; bh=GehI3 XXL4Ad36kvz3hlcm2rtGolWxFPbZ9vzX2/j/NM=; b=XsAI4yq4Hv07BGMcdWSJj H2BhKzAxRP9lg5nREyxIaon4dtC3I7d0byvHtxHYgGFWDvfyjGmH0hcCG5oPX+Kb t0NAWQrkZsb03SkVfJ0VBEKze8QMIJqCtl0c8B6w55aIBarRbEwoIASNNYfAInAZ 0VQFn6n9VoaKiDPRXRSDye2zE92nbF9WgU3/1dwqCjlhaLwu7Oj8zr1JJ8O/HEKW bVXMOHE8mHSmpnGC6K0b2Q+Id21O+vF7blGyL78x3ULPSckxC+hSnNVBBhRfs+yw I/j803h33kfBd9VCPLa3NQ9rmSpTQhN+YfEhfWwyZD6ve+cbOPZUFekjxuIILmEq 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 VV9AFcosktUv; Mon, 8 Jul 2024 21:18:49 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxnL23Q6z6Cnk9V; Mon, 8 Jul 2024 21:18:46 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Minwoo Im , Stanley Jhu , ChanWoo Lee , Naomi Chu , Po-Wen Kao , Yang Li Subject: [PATCH v5 09/10] scsi: ufs: Inline ufshcd_mcq_vops_get_hba_mac() Date: Mon, 8 Jul 2024 14:16:04 -0700 Message-ID: <20240708211716.2827751-10-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-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 ufshcd_mcq_decide_queue_depth() easier to read by inlining ufshcd_mcq_vops_get_hba_mac(). Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufs-mcq.c | 18 +++++++++++------- drivers/ufs/core/ufshcd-priv.h | 8 -------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 0a9597a6d059..ef98c9797d07 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -144,14 +144,14 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); */ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) { - int mac; + int mac = -EOPNOTSUPP; - /* Mandatory to implement get_hba_mac() */ - mac = ufshcd_mcq_vops_get_hba_mac(hba); - if (mac < 0) { - dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); - return mac; - } + if (!hba->vops || !hba->vops->get_hba_mac) + goto err; + + mac = hba->vops->get_hba_mac(hba); + if (mac < 0) + goto err; WARN_ON_ONCE(!hba->dev_info.bqueuedepth); /* @@ -160,6 +160,10 @@ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) * shared queuing architecture is enabled. */ return min_t(int, mac, hba->dev_info.bqueuedepth); + +err: + dev_err(hba->dev, "Failed to get mac, err=%d\n", mac); + return mac; } static int ufshcd_mcq_config_nr_queues(struct ufs_hba *hba) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 668748477e6e..88ce93748305 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -249,14 +249,6 @@ static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba) return -EOPNOTSUPP; } -static inline int ufshcd_mcq_vops_get_hba_mac(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->get_hba_mac) - return hba->vops->get_hba_mac(hba); - - return -EOPNOTSUPP; -} - static inline int ufshcd_mcq_vops_op_runtime_config(struct ufs_hba *hba) { if (hba->vops && hba->vops->op_runtime_config) From patchwork Mon Jul 8 21:16:05 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: 13727049 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 88A3B14D2A3 for ; Mon, 8 Jul 2024 21:19:26 +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=1720473568; cv=none; b=j47QotLMjjYxzH2pTo57/gjjPwbbGiqJDVm1QJxFgEINtsP/R6q4poOblt3w5rHPfJcIYRYbGR19yQkgLoAnLE22o49ds7teSRSVkby15WniOd5BgHcSHv2xQP5wgmCpqCsZQq3AWD8nyo19CSTVdblwf18KF252s82iYdlFt9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720473568; c=relaxed/simple; bh=jjx+GqcSDnE663D3PJ1XAhhSANs3UMkWrQiOwxGVVxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i9UA+cwKe/DeyaAAQijSvWRMikP0l7WBs+P7tCLmtF8ddJ5hIRKa9gd8f14g+xIXW2JK3pA5xaFpmdbHG3Jc4/3E2iFKIvOlbnH2k9EGv9yKcAxdeA7QEIC1w5gUsU6Pvk0Dehq8D57EO4ATjglD1vum8whjxvS85RjRzowNb/o= 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=Y8g8ctcX; 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="Y8g8ctcX" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WHxp622cFz6CmM6L; Mon, 8 Jul 2024 21:19:26 +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=1720473552; x=1723065553; bh=/f13e zMkTqOft6w0SXyVP9yXp/obffaFESgQ7DPdowU=; b=Y8g8ctcXx5KFvJmQ8D0TC ZqexEkxMcKMDocVuYOVx69z39Y3t/ZFFcXBJQt+AJ1A0XU8jmOMDAgzWvvm2IhcC WCfGhrpk578CO28Xvu7dMCjzXUgM9SjNumfExKNJ0yXLht1M3wblmI8S6FpnedjL ATSkkMffFXUkMvTW5h0VaWrAuo5elWwbOO0akzU9x8wf5gEPtB3hlqFUvJOy6K3I ZIt4Ekgph/slV7mroS9haUlNakoyxzKX5IZoRf+Yn/zg88x5LIGL+nl/vRs/lBGr J+Mu7WwHeQ8DnWkUaa8VrAs4Iy6NxaKQhgKxfKR8Kos+c5LYxPaiftBP3k1iecPI 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 qit4WRcD33xV; Mon, 8 Jul 2024 21:19:12 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.132.0.90]) (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 4WHxnl4rC0z6Cnk9V; Mon, 8 Jul 2024 21:19:07 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, peter.wang@mediatek.com, manivannan.sadhasivam@linaro.org, Bart Van Assche , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Minwoo Im , Stanley Jhu , ChanWoo Lee , Naomi Chu , Rohit Ner , Yang Li , Avri Altman , Andrew Halaney , Bean Huo , Maramaina Naresh , Akinobu Mita Subject: [PATCH v5 10/10] scsi: ufs: Make .get_hba_mac() optional Date: Mon, 8 Jul 2024 14:16:05 -0700 Message-ID: <20240708211716.2827751-11-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240708211716.2827751-1-bvanassche@acm.org> References: <20240708211716.2827751-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 UFSHCI controllers that are compliant with the UFSHCI 4.0 standard report the maximum number of supported commands in the controller capabilities register. Use that value if .get_hba_mac == NULL. Reviewed-by: Peter Wang Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufs-mcq.c | 26 ++++++++++++++++++++------ drivers/ufs/core/ufshcd-priv.h | 1 + drivers/ufs/core/ufshcd.c | 3 ++- include/ufs/ufshcd.h | 4 +++- include/ufs/ufshci.h | 1 + 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index ef98c9797d07..70951829192f 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -138,18 +138,26 @@ EXPORT_SYMBOL_GPL(ufshcd_mcq_queue_cfg_addr); * * MAC - Max. Active Command of the Host Controller (HC) * HC wouldn't send more than this commands to the device. - * It is mandatory to implement get_hba_mac() to enable MCQ mode. * Calculates and adjusts the queue depth based on the depth * supported by the HC and ufs device. */ int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) { - int mac = -EOPNOTSUPP; + int mac; - if (!hba->vops || !hba->vops->get_hba_mac) - goto err; - - mac = hba->vops->get_hba_mac(hba); + if (!hba->vops || !hba->vops->get_hba_mac) { + /* + * Extract the maximum number of active transfer tasks value + * from the host controller capabilities register. This value is + * 0-based. + */ + hba->capabilities = + ufshcd_readl(hba, REG_CONTROLLER_CAPABILITIES); + mac = hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS_MCQ; + mac++; + } else { + mac = hba->vops->get_hba_mac(hba); + } if (mac < 0) goto err; @@ -424,6 +432,12 @@ void ufshcd_mcq_enable(struct ufs_hba *hba) } EXPORT_SYMBOL_GPL(ufshcd_mcq_enable); +void ufshcd_mcq_disable(struct ufs_hba *hba) +{ + ufshcd_rmwl(hba, MCQ_MODE_SELECT, 0, REG_UFS_MEM_CFG); + hba->mcq_enabled = false; +} + void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg) { ufshcd_writel(hba, msg->address_lo, REG_UFS_ESILBA); diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 88ce93748305..ce36154ce963 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -64,6 +64,7 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, struct cq_entry *cqe); int ufshcd_mcq_init(struct ufs_hba *hba); +void ufshcd_mcq_disable(struct ufs_hba *hba); int ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba); int ufshcd_mcq_memory_alloc(struct ufs_hba *hba); struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba, diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 4c2b60dec43f..1ba5668b0700 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8754,12 +8754,13 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params) if (ret) return ret; if (is_mcq_supported(hba) && !hba->scsi_host_added) { + ufshcd_mcq_enable(hba); ret = ufshcd_alloc_mcq(hba); if (!ret) { ufshcd_config_mcq(hba); - ufshcd_mcq_enable(hba); } else { /* Continue with SDB mode */ + ufshcd_mcq_disable(hba); use_mcq_mode = false; dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", ret); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 3eaa8bc7eaea..52b0b10cca50 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -325,7 +325,9 @@ struct ufs_pwr_mode_info { * @event_notify: called to notify important events * @reinit_notify: called to notify reinit of UFSHCD during max gear switch * @mcq_config_resource: called to configure MCQ platform resources - * @get_hba_mac: called to get vendor specific mac value, mandatory for mcq mode + * @get_hba_mac: reports maximum number of outstanding commands supported by + * the controller. Should be implemented for UFSHCI 4.0 or later + * controllers that are not compliant with the UFSHCI 4.0 specification. * @op_runtime_config: called to config Operation and runtime regs Pointers * @get_outstanding_cqs: called to get outstanding completion queues * @config_esi: called to config Event Specific Interrupt diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h index 8d0cc73537c6..38fe97971a65 100644 --- a/include/ufs/ufshci.h +++ b/include/ufs/ufshci.h @@ -68,6 +68,7 @@ enum { /* Controller capability masks */ enum { MASK_TRANSFER_REQUESTS_SLOTS_SDB = 0x0000001F, + MASK_TRANSFER_REQUESTS_SLOTS_MCQ = 0x000000FF, MASK_NUMBER_OUTSTANDING_RTT = 0x0000FF00, MASK_TASK_MANAGEMENT_REQUEST_SLOTS = 0x00070000, MASK_EHSLUTRD_SUPPORTED = 0x00400000,