From patchwork Tue Jul 2 20:39:09 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: 13720314 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 7CD871CF8F for ; Tue, 2 Jul 2024 20:41:05 +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=1719952867; cv=none; b=qxzkbGNSe9uAO6yaDFT5z7VEAD+4ccUmoGVqznrPN7ymtG25yW3oMqFo6ZXUyezAEIz9hSc3o0kJ5PzwODmCI3SBKNP4KcydngZwdjmKKT9FuIOo+J9ALDDR3tqRafVgZj6xP6JRCsDgVa2fBTjx8P9Z+nPUAm7PVavpqxG//FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952867; c=relaxed/simple; bh=BAsc5MLO+gwJmiwQcYML31t1QPduHNpHmT0E31XYwoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dN0Yx3yaoElIEGBK45qGRjvtb95efcORGRl7D7oneP8PqRWg/UxKEiUYNXiKiHJ1MTtZUMHnYhvfvZxN8U/BFVFHCbPmrHqcDdLAL40FQgxj2bPERqh6a7EuGpYbMO2QGZxJVUkNY7Ln6GYMPxrAlYkrAUjlJKEpNXB+gcbJBzI= 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=bIIkIxlp; 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="bIIkIxlp" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFDc67zsz6Cnv3Q; Tue, 2 Jul 2024 20:41:04 +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=1719952861; x=1722544862; bh=d2wWr BfTigkQD5z/WfCBGOH20AyrfifTkBSPKGeJhzQ=; b=bIIkIxlptPuF1EiQcFUAr FbjVwllJlikvqtyNTxwmmM5iiDhXFP1iLxDmXt3DwqpHWAdJIYIaJmWKcspyX89Z BPTFgnvGVcGaaFMru8bHrDEcfG/hiUw0DBId9UbYYuLq5yhvDh3+wayXiz6hVAv0 /cmgS5MYVNUKdkfSV8BVP4PLPNAr/H+1QcQ7AAHGti51fbHyaQvJae/aWN1YMu24 712j/d7MUlumy7wvMZ5KVNCTT/ZLB1KIhnUNT9zef25DDvQo+B3oWg1Tv+4WDcqI O4adnhw/V9KTC/gpyH5Rw8jeV7EQJ38UalPS0xveAAWVwJlB5/8DUmbCJigX1Vj0 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 NubCWLbfKFMb; Tue, 2 Jul 2024 20:41:01 +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 4WDFDY2Mmxz6Cnk9X; Tue, 2 Jul 2024 20:41:01 +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 Subject: [PATCH v4 1/9] scsi: ufs: Declare functions once Date: Tue, 2 Jul 2024 13:39:09 -0700 Message-ID: <20240702204020.2489324-2-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 --- 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 Tue Jul 2 20:39:10 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: 13720316 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 8F9D61CF8F for ; Tue, 2 Jul 2024 20:41: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=1719952886; cv=none; b=rLRHpHMJhUP8N4afTJmgWyGcMzQSUmyAYVPZbHsrbE1xiLPzMMRPxEoR4eZV5P1HvcpJ5n7bb/iq9LMPQ34KpuLAwtIz0qNZXIBXP2iawbma1podaewKK0cku+vR2jgXnEp37uRDGqr5F9CvzwvS4nSUEiukBeNS2BQqkpuL8cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952886; c=relaxed/simple; bh=SOraicAUZ0aZfKsuK0+YlzNtWzG94d/1hk+08S1d/vs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tLAJ+c7Qamd1P7aHUHlJwmgjpIBqGqG6wzExOg++VdqAK1XQzR55BTEr9KddxtUFfFLOQSierOSJRZG6wSe4ChaWZu0fm45CGGVqcco3+YUEH5/NPBx6y0CZN8C11r/HgUREXscS0s7rVrpJ70Ej+HblwFMeT4hOsl1iph42DMo= 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=QtI7qoY6; 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="QtI7qoY6" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFF026YJz6Cnk9V; Tue, 2 Jul 2024 20:41: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=1719952870; x=1722544871; bh=wjTF0 v8K+dt1+ViHhgyQIsJzW10t3VvN78KjdULOZKQ=; b=QtI7qoY6TGVQkVQMQdtE6 3TJEl17f9P4PAzZELyW9VmgYIiusir+2qoLupzzmmvZtsc07i0Qc3ivh+2RcSw6p HprOk38ZZx2dADRsr+z/WFgkvZJCAnnOAdOFMVxeQCmSDWl7TZppX4oFlZMugHEB 5xqZUswEhGhtkOI3ve1fO1ui8YicCTzcef/qAgdJl54zBosrnsbxmXoJSLR132xA yZFAzziaukkO6HtoJbjqERNhsM/nDcVDCT7UkFJYYf9XxethbGToRejOUJx3/seQ v6cILOucpIe76e0HxXXBGCD+fmzyLjHxT/VmZ85ct7zF0dRqSTLLBHVaYfaZj3gx 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 TJqWWr_xQQhl; Tue, 2 Jul 2024 20:41:10 +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 4WDFDj45ssz6Cnk9X; Tue, 2 Jul 2024 20:41:09 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daejun Park , Avri Altman , Manivannan Sadhasivam , Peter Wang , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Andrew Halaney , Bean Huo , Minwoo Im , Maramaina Naresh , Akinobu Mita Subject: [PATCH v4 2/9] scsi: ufs: Initialize struct uic_command once Date: Tue, 2 Jul 2024 13:39:10 -0700 Message-ID: <20240702204020.2489324-3-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 1fc08e34aaf9..b7ceedba4f93 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3993,11 +3993,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, @@ -4015,11 +4015,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, @@ -4054,11 +4054,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, @@ -4111,7 +4111,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" @@ -4120,12 +4125,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); @@ -4155,7 +4154,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" @@ -4189,10 +4191,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); @@ -4325,7 +4323,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) { @@ -4338,9 +4340,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); @@ -4381,13 +4380,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); @@ -4405,13 +4405,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 9e0581115b34..d4d63507d090 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 Tue Jul 2 20:39:11 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: 13720315 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 A456F1CF8F for ; Tue, 2 Jul 2024 20:41:21 +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=1719952883; cv=none; b=sCZoenljLmmPQ6oEeNGl7TPGbH4+h2Kk/qlV8SqSNdcwdJLLBDAPdSk/4jtHuyvrrJ4xXo6ny1qJqeL3iGJUavGZLb+Tz0vkkslypJTvWqeS8UGF3VmB53X7i8i8+9iRAqEFx8cAoRq7HfsSkfWc25LbJtJk/Avz/LYdNFfnjW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952883; c=relaxed/simple; bh=EBiV7D4z+WEztx2RgRRU7jfIZTy/vzjL6zISW7O5fco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jP5jn36HU1ULpjqNoujux16LhccJFbUUVcObthx6JOiF7J49m5cpbQ/uZZqo9ANaOLi4JAoDxsP085rze0rUUYstjKngOYRXH+qU3TuBf4ZybFILc4n6GQQLqN/Suem8pU4WmFZhcFymog7LAjjGiOMx17FG1zuHX+ZvDMtQDrk= 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=Bao10MbR; 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="Bao10MbR" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFDw6r8lz6Cnk90; Tue, 2 Jul 2024 20:41:20 +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=1719952876; x=1722544877; bh=4ziCu nqHIUeWHu7uh7TCdc2Tl6mLk+QYUQDvl0l8OwE=; b=Bao10MbRT/6qS/0CsfmKu KdaXlQVO71Iz4WXxCYgAoOtyEmm240l4cESl7XwDTf2qZeEy5B0ayb+oByv+/qnM A1Fq6Vm2S2hURoNd55ZK3vKu1ylj/I41IHDl9mp7mex52f8hGiggkSO2/UuLyH2r TioFSBM7+9EXkDlVKeas/lDnMGorXzJsHrqyf3GLzElQRBg8xv3Xfn1IZTmYJXS6 S8/0JYWM2gFwhCe3ZfvCCokQxZIe9KVHy0FTkCUcH2YW3M89RcMWoieDbW2kZT6J XLyYNCWT7AIUprEahNy0wemkysXd2eKpiJ6MNjFjvrP7EfpRrBMSif1Qv2IFuAmS 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 68m7qmoXpt8y; Tue, 2 Jul 2024 20:41:16 +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 4WDFDq0nR5z6Cnv3Q; Tue, 2 Jul 2024 20:41:14 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Manivannan Sadhasivam , Keoseong Park , Peter Wang , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Andrew Halaney , Bean Huo Subject: [PATCH v4 3/9] scsi: ufs: Remove two constants Date: Tue, 2 Jul 2024 13:39:11 -0700 Message-ID: <20240702204020.2489324-4-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 b7ceedba4f93..9a0697556953 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[] = { @@ -8958,8 +8956,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 Tue Jul 2 20:39:12 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: 13720317 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 27C721CF8F for ; Tue, 2 Jul 2024 20:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952893; cv=none; b=MmwCmpN7DajUk2pXTPX0hJJe5zRHIOvtl7owxdv12Fssa7NXq4Ok0rEWU7ZMpYTnQDlLvOr9p7MUIwzUVJMHtFMP+16A8q28isi+gNFa2417Fv5EKxAN88ojw8RJBewaKN0VfCcCb24nOsV1B2+xijuBpwGcVtrRhztOt8cfRqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952893; c=relaxed/simple; bh=iIelxTrUEyCu9m2YbccZUhxOKRIC2Q0+5C60rs2R+S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fXmntPe0fkASPpEgFaHKq3f3J1WJEmRHC4cdCs4vJJmKwn4kgiX9+V4hbuZW7ZPHlimIlHrQWiX+JoPYz91bQP14UNP223kIrg1l86MJeVjN/TllVFogHOvmRZHGeW7CIZmuNAixyO1m9UTl39wJyacXT3Mm8cW/hYAZT35xSSg= 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=c8Gw72Ts; 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="c8Gw72Ts" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFF64rT6z6CmQyM; Tue, 2 Jul 2024 20:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1719952884; x=1722544885; bh=iejQk SU/hIQcf0C3EA4NXqSVrmp7WFjlGQtyV9AAy1w=; b=c8Gw72Ts0GYF9VbLGUGeV Aoqcs4P7Xp5XmuZPPa/1fvDlD9/SmpxWmX0U5ApY3d9imv3SiYEgsLpUAmDJFXgt kR0yGt3ufvhOJRb/tXBhrq3eE9NiAILsCeB6GjD9qBIjjiuPqDh/HFuk6XDDu6oq rCc5W1GhsRf/GPC+K1q3wBNFrmBg2Pf3r5oJvEXD6P4PJ01//YbL40EmxHQ2/gwl Xu+APlAKPm34RsTWydFcwvtQ2kmKnyH2oxRgpSQYUAWLHUjQtbcuuJsbQb/VHYK9 X2x3A4BdeI3XvC2GLIXQMfD79hNnBxKfTbEc2vE79Y2WpCDwOMK98KeGrs/MybnC 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 KfEnlreOec-H; Tue, 2 Jul 2024 20:41:24 +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 4WDFDz5MZ5z6Cnk98; Tue, 2 Jul 2024 20:41:23 +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 , Avri Altman , Manivannan Sadhasivam , Andrew Halaney , Bean Huo , ChanWoo Lee Subject: [PATCH v4 4/9] scsi: ufs: Rename the MASK_TRANSFER_REQUESTS_SLOTS constant Date: Tue, 2 Jul 2024 13:39:12 -0700 Message-ID: <20240702204020.2489324-5-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- 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 9a0697556953..2cbd0f91953b 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2401,7 +2401,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 Tue Jul 2 20:39:13 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: 13720318 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 B7DDC201246 for ; Tue, 2 Jul 2024 20:41:35 +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=1719952897; cv=none; b=X421leHrbzb/jcNhYUBsGgkPSEGJUzJdPWFXKaXaANtyMCSTFBQ4msJ0kXHAA6ZFhjxAdBLYkFI2gDyc0q8Bx/SEvxLCzPpG5uEco5bnMGZ1QtfheU9Y3cWXFjYNlgwLhl7ZnXNra2EhOeaP3Pok0oqImYdEws6pyq7UcX2FuLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952897; c=relaxed/simple; bh=YjQbZqUwcCLmfbhkyRd0rH3X9WO7x+lPm3CeHYqHzF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TTVLXAO1bG6cHg9ORGz0fspn4w4GoRiX/Z0o1+RGwVxvXpDVXjd7TST8NzL05Q325hIX8gGpLwZ+jTcOGVYUvTkox7+dWHVhbF2dZHcPLsl24voNkaPH44sLLaqxLh2Zl6RUChF6LOr0iYKLubT68vAGC25mtyY/hRr7DdM6h3A= 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=w+9O4YM2; 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="w+9O4YM2" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFFC248jz6Cnk98; Tue, 2 Jul 2024 20:41:35 +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=1719952890; x=1722544891; bh=A2j8G UDqyaNQ0NQMKq5c00lJtMK/+ICJoy3fvc35Au0=; b=w+9O4YM2g5TN0IQkKhClp CIEBWAUl27iewRf1rlBbWjUerEKjHv9zHQl/mWqRIEW9/o8PWIIwG+7xKgiMEQ64 MmRqruYVHTTZZZz/h06lxj7FUvx1ybX44rvKO6RQzNvRk0NlAlaapDTq1j0jdWf4 G77ynehYbQAi5BpZbYVbBKLNLkVxzhZdDevPT7kYYuUtBrkzcy/3lvT1tMOa7JBB w+NYGtJx9+TEugYFfk6n2p7IloIm4U0orOSK8TtZEc1jzWt3/KJVd7Z6Ct2fcyhf 19ILqIhQj18FdLEtaE+6rmxthVGo6kk9VWiIa0sSduobCinLGwuv9az3FrAbfVC0 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 YBovGD3id51x; Tue, 2 Jul 2024 20:41:30 +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 4WDFF50fL2z6Cnk9V; Tue, 2 Jul 2024 20:41:28 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Can Guo , Peter Wang , "James E.J. Bottomley" , Matthias Brugger , AngeloGioacchino Del Regno , Avri Altman , Manivannan Sadhasivam , Andrew Halaney , Bean Huo Subject: [PATCH v4 5/9] scsi: ufs: Initialize hba->reserved_slot earlier Date: Tue, 2 Jul 2024 13:39:13 -0700 Message-ID: <20240702204020.2489324-6-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 Signed-off-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- 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 2cbd0f91953b..178b0abaeb30 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8678,6 +8678,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; @@ -8699,9 +8702,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 Tue Jul 2 20:39:14 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: 13720320 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 533C31CF8F for ; Tue, 2 Jul 2024 20:41:49 +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=1719952910; cv=none; b=TkU+GzVxfiYWRhQzOaiNAodvNiUUDNDuE9pjSJ43PDngvs7nkzVPoQ4FFfuGz+Hqjuh4BUJcIYdZLIBeubU9frxsJ1At1d9k7mstgky+WiUFyfgW59emGonp1xWdpeGVrQFHf+o5NfJEOe/w5Wn4HzzVIUDhHeua4frJnBI/4u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952910; c=relaxed/simple; bh=zlCjUk2FCBdfEh/htgA+ESN6In75xeDPxZzjvPj2/wE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=af6kgZ7RlGsfR9z284Nq7mkgJS3vd/hOP8uQgQPxwoDKtann+WmYhubcSFNPokHjSfA3y89x7TjEzAcHgL8LnAbn/ET4BB8oQzRxbqN+cB5mPmx5eVQg3KImYTdjtBpjPRcDIb171OopoAhorlCQK3/rlbb9FJLtkJER9cp6l2Y= 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=c1/snu1H; 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="c1/snu1H" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFFT08n3z6Cnk90; Tue, 2 Jul 2024 20:41:49 +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=1719952899; x=1722544900; bh=BIjbC YsQwe4vVykFmL0dUV6c/uCuoKxE++Ds972Uv6s=; b=c1/snu1HUXGEeaXhsAJGj oAxvApcLvSXpoqxTPK7rPeoFFwjehSPfHfH1jsMPePoZlo8Hwvzhxs+tMOq3A89R WBvON4bMaLyopHhCUt6oWGoex6Co1bDUXbi/i/9Qmi3shMfXLM7i7j5l1ugHD91H eXFUR8W0PP0a0gmQPlQxz4NplQ/+LmUMrMyAFWlVaB+hj45+5BwmJXUpcYg/D+Wg tzQ4yrWGpwKWrwfqs9KRoKu+4huwuwK29YjZcLLCCFpFBThVFCKkmJRXYqKTNU7V ukQSl74Skn2enFSQKhpbuS0iDjWGVoZS0XxohE4bIo3XRsn6r4oADyqVnqYfglOI 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 DMfsYboba1qR; Tue, 2 Jul 2024 20:41:39 +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 4WDFFF6q8Nz6Cnk9V; Tue, 2 Jul 2024 20:41:37 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Avri Altman , Peter Wang , Manivannan Sadhasivam , Andrew Halaney , Bean Huo , Minwoo Im , Maramaina Naresh , Akinobu Mita Subject: [PATCH v4 6/9] scsi: ufs: Inline is_mcq_enabled() Date: Tue, 2 Jul 2024 13:39:14 -0700 Message-ID: <20240702204020.2489324-7-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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(). Signed-off-by: Bart Van Assche Reviewed-by: Peter Wang Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 28 ++++++++++++++-------------- include/ufs/ufshcd.h | 5 ----- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 178b0abaeb30..4c138f42a802 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; @@ -2301,7 +2301,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; @@ -3000,7 +3000,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); @@ -3059,7 +3059,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. @@ -3169,7 +3169,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; @@ -5560,7 +5560,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); @@ -6201,7 +6201,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); @@ -6458,7 +6458,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)) @@ -7389,7 +7389,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) && @@ -7485,7 +7485,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 */ @@ -7563,7 +7563,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. */ @@ -7596,7 +7596,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", @@ -7623,7 +7623,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; @@ -8732,7 +8732,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/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index d4d63507d090..c0e28a512b3c 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1132,11 +1132,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 Tue Jul 2 20:39:15 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: 13720319 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 90779201242 for ; Tue, 2 Jul 2024 20:41:48 +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=1719952909; cv=none; b=i5buE7ZJtrtbiBurRg3aziBlFYb5lPn4y3qzb3QnzrJuf4WSMZN9Tlp7enMAz3ThrK0jHeu/Pj92HD4FWOpJStxNma2IZmtwOd3uno+zwgaWJjEq3alAyXT9MIUsqJAi+3Mc0LHN4STiGqwookX2kKlrBfATbV54GyYufdDh1NA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952909; c=relaxed/simple; bh=bzb6RmtmFRoGr4+TzuAjhKVqbDm5RYu94wfzFJmU7kU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=boQ0rJsVSaEsvjQZqiENbYT5jSbC68zZy8iWudUnlVmJOTR9jQZq0D3zSxxmUfHgm0bySm4YdruB/PKJgwCnrixFeRld+pifQ/HC51jKAs5kBtsKyVYSOSp8Sk9Wmlv7qiwEpyx6OM/5QnB/lcSS1lAbGJ1yd2wB/4F2z0LBk3I= 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=wrFJ+xBO; 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="wrFJ+xBO" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFFS2GHLz6Cnk98; Tue, 2 Jul 2024 20:41:48 +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=1719952904; x=1722544905; bh=tkMeu 8xUg2xvCJQPEOfjRjwoos0kehvNBPpNfTzX74w=; b=wrFJ+xBOWiIqkXdoeSbYa cs9Ou/52jEMIU32zdAR3sFuCsp6pxvI2LDKuIcQgCX6QKk6lIesZwYkJ2hzEZwal JZGxp0fprGiCn6Jv8CL6OJQSO+gaRHThHB2EyJg48lzUnV41vZ35WG2LdtVrqo5r s2h45BRHyuXGjuHgMUmr7AxVv/dItWk8+mkzPPSnL665P/9PMRgLZybrq9GenPqM Pyau7VHH8qtpUNejKW56LIpoYebQd9uT7O89C3Da/OdRmpWN/RZHhqj9zOWIP5GD xsc1ztX9N73yDNYMHuuwVOCjrqZTMFbCyiNyztxsIw1yNHp6YjcTFlAC6AKoMzUD 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 wLbtFZ6USVaU; Tue, 2 Jul 2024 20:41:44 +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 4WDFFM1Rc1z6Cnk90; Tue, 2 Jul 2024 20:41:43 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Avri Altman , Peter Wang , Manivannan Sadhasivam , Andrew Halaney , Bean Huo Subject: [PATCH v4 7/9] scsi: ufs: Move the ufshcd_mcq_enable() call Date: Tue, 2 Jul 2024 13:39:15 -0700 Message-ID: <20240702204020.2489324-8-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 and also the hba->mcq_enabled = true assignment from inside ufshcd_config_mcq() to the callers of this function. No functionality is changed by this patch. Signed-off-by: Bart Van Assche Reviewed-by: Peter Wang Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 4c138f42a802..b3444f9ce130 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8702,9 +8702,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); - 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], hba->nr_queues[HCTX_TYPE_READ], hba->nr_queues[HCTX_TYPE_POLL], @@ -8732,8 +8729,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 +8756,8 @@ 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); + hba->mcq_enabled = true; } else { /* Continue with SDB mode */ use_mcq_mode = false; @@ -8772,6 +8773,8 @@ 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); + hba->mcq_enabled = true; } } From patchwork Tue Jul 2 20:39:16 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: 13720321 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 E91F220013C for ; Tue, 2 Jul 2024 20:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952921; cv=none; b=lE4fYIcJSOIr8AO5pJEDxE9OV7cpzlb8BfQnyEO3jH5lzy3LNwUxkV78nh4E8pHXmBDe92QfGM5lTfGPyWBQ9n6S9BtSHi9dRqpawqaxz/Zc6CBjwdxRIkCGhMVeGH5r42ZwPJEvLjujHEQRw9pqHkhGatA54jnc3sDWrtdtrcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952921; c=relaxed/simple; bh=+KiVxrkLJvOBGW9vaniobU33F3tUXznqOBPtj6O7ATc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WlDzUug/skB380w/S2dvjlNN8DPvSQ8uTTp2NXTc9kPzb9DHpj9b0Jhy+LFHYjoa3tKNp9PRDTxxn4Nhu99hcGdmWVPO14kIraxoOII1Vn9WDrpSxQqZbo9GYh1hai2WmcM1vVe1ZtVU22I9nbB2ICKLauswI5dc/h0oywHmvEI= 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=gZ2FkIAR; 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="gZ2FkIAR" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFFf4w3bz6Cnk98; Tue, 2 Jul 2024 20:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1719952912; x=1722544913; bh=u9JIS Wyai+a5Sr7d7JxZ9E06wEF8lgPVBsJf9kG1t5w=; b=gZ2FkIARH+QcFfZdq7qaT IEncqZCY8cLErd0VRbHb7KkkPsAeQht9rbCT7eruzsuL9sGilDywFvc5ZopOH2mx C6KmQq8VWRO2Wq+C+IF6Fb8RosQ89wBtMUq0/Qpcxg5cs/eDdWuoXfACTyMQKCg+ ChRqvjjNYILG4zyx84iUe64FWy11y8lCDqlhk2BTCjRx9Sz3y/2YtXKZnwcWYcyD 5QC5FMfCQTEv5vbEuy6sqMx6OrMV7MPUsBsNXiwXnLWQnYDMcxhhlHTosfCgtCUG kA9KFSYyWzCG1hCG5biPrsKhyK76XL3grqCIiSv/BPUIklbN8l3GIBJcjvvHzlI1 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 QX5ZUweONf6C; Tue, 2 Jul 2024 20:41: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 4WDFFW2vmxz6Cnk90; Tue, 2 Jul 2024 20:41:51 +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 , Minwoo Im , Stanley Jhu , ChanWoo Lee , "Bao D. Nguyen" , Yang Li Subject: [PATCH v4 8/9] scsi: ufs: Inline ufshcd_mcq_vops_get_hba_mac() Date: Tue, 2 Jul 2024 13:39:16 -0700 Message-ID: <20240702204020.2489324-9-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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 --- 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 4bcae410c268..0482c7a1e419 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 Tue Jul 2 20:39:17 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: 13720326 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 EB7091CF8F for ; Tue, 2 Jul 2024 20:42: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=1719952947; cv=none; b=js4XR31LPHiOCwBr8xG84IChJTBep1XFmq9NxXZ3mDp4QDahinPkBDH8BIEbnP+jNgROzL9U7Bl5MD4LR4M2Ds/ILh9ZVF+KMzwxVKjQ1QeaU/gJhljiC1F68c87Ps9oER7atuy6m0k8vfNmzU0OZa2z9BMNevQUqg7xBqVU/O8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719952947; c=relaxed/simple; bh=CixEfgz4Pls5dTqPKm57mfd+7qp7n+vuURfM0Ppxk9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVl00oZxwWAdexm7WIzlGtHpI7ecFT9tGrcqwZZTqavZiUoW3ub870l/5QdVlLZ25Cw4xnTm45o3oGYJfq0EdZCaVmHtAXE/mSp+5BIDQ/M2TbD1G5+UL2QV5SqSXozTLxGSTDOr8KXgII6G4z35KItriU/0WSFKgG2AdvQ/M6I= 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=0U4an7Mc; 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="0U4an7Mc" Received: from localhost (localhost [127.0.0.1]) by 008.lax.mailroute.net (Postfix) with ESMTP id 4WDFG83cwBz6Cnk98; Tue, 2 Jul 2024 20:42: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=1719952932; x=1722544933; bh=l54IS 2i4FmXEr8o3RMmF3xKfwh2Q18OyvSzsfChUQcI=; b=0U4an7Mc6pxKBR2EFWaZk UEkzTpIcGDhXqJUc7pl+RXCNa1DeLjW0pG0vxlIlA8Gj/2wWjPHEPK/IC/O/wa4S D0cAybmVc0u0dSEEdFunUwecasapOAFyn4HC1dq3nYgIT1YBD2AaZLDf74t69JI0 hqXyosSP/OFAPRalR+ublMFDDljW4OyI+M9WKLGdThe5PtESZhp7q+MHZw2PJFBP SBHSPpo2vocF8pD1u6n1D8nRI0U1UbpOqHrK5yQpxQvEvpGUTFKudYTJ38EgMfrt nzlHUqNn2Sja8O/xpA2/Q07lEO4KEdIcuCnal2g5l4rfqX3Nj+zqcoSQ6bqf0jZf 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 YIURhle2IIQV; Tue, 2 Jul 2024 20:42: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 4WDFFt4V1lz6Cnk90; Tue, 2 Jul 2024 20:42:10 +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 , Minwoo Im , Stanley Jhu , ChanWoo Lee , Yang Li , "Bao D. Nguyen" , Avri Altman , Manivannan Sadhasivam , Andrew Halaney , Bean Huo , Maramaina Naresh , Akinobu Mita Subject: [PATCH v4 9/9] scsi: ufs: Make .get_hba_mac() optional Date: Tue, 2 Jul 2024 13:39:17 -0700 Message-ID: <20240702204020.2489324-10-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702204020.2489324-1-bvanassche@acm.org> References: <20240702204020.2489324-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. Signed-off-by: Bart Van Assche Reviewed-by: Peter Wang --- drivers/ufs/core/ufs-mcq.c | 20 ++++++++++++++------ drivers/ufs/core/ufshcd-priv.h | 1 + drivers/ufs/core/ufshcd.c | 6 ++++-- include/ufs/ufshcd.h | 4 +++- include/ufs/ufshci.h | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 0482c7a1e419..b2cf34a1fe48 100644 --- a/drivers/ufs/core/ufs-mcq.c +++ b/drivers/ufs/core/ufs-mcq.c @@ -138,18 +138,21 @@ 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) { + 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; @@ -423,6 +426,11 @@ 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); +} + 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 b3444f9ce130..9e0290c6c2d3 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8753,13 +8753,15 @@ 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); + hba->mcq_enabled = true; ret = ufshcd_alloc_mcq(hba); if (!ret) { ufshcd_config_mcq(hba); - ufshcd_mcq_enable(hba); - hba->mcq_enabled = true; } else { /* Continue with SDB mode */ + ufshcd_mcq_disable(hba); + hba->mcq_enabled = false; 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 c0e28a512b3c..6518997930f3 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,