From patchwork Thu Jun 27 19:58:27 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: 808622 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 549326CDC0 for ; Thu, 27 Jun 2024 20:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518418; cv=none; b=SqgdVR44XLYAA4WS7vUxNoZAe0RLs7CoHcKfQZydXfYgnX7Hv2g0jSPeTkPi5bcptr4A+K414b+nVF1QfFgtaSulmTs9t5ww38E4YllOZM0i7vutVM9HJsuAy40Li7xl2ddzhV1HDPB04Ha/c2R53TqUhLFT3dQ9Hyn/ls4vJoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518418; c=relaxed/simple; bh=70gx9DD1sqqNI4T9UF6iLImLyGhcVM/49EpFzj95A+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P69cxbqPpCQazCXAZ7ZEX1v0Q1W9XkdSBW3rm7DzrBVvTyN3mfQoD83yREIuMMk5ilq0RKgR4DsA7I5jYshT4yeJbw1hA1VBEW0j7UmTJS+0oX3iYw4dzP9AW6ThRACZ7CRs3mpTdNI7oCBzi3EDpQfe4yU6d1SiBerm6avqt0g= 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=B1IyaNj0; arc=none smtp.client-ip=199.89.1.12 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="B1IyaNj0" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98Yq66VpzlgMVW; Thu, 27 Jun 2024 20:00:15 +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=1719518413; x=1722110414; bh=Ib1Af kKZwcIYq8QMbuAo8sOSkNcr0hYxTnvpFMmDejw=; b=B1IyaNj0ULBm5M3hJLW0I eTX6j1xWS3pzjfGonjh2eijnDAJdRHTncXFihoFXXQnYGZlW1PnIJFN7Q3PYt9vh Sg5bL3i568qfUUIHACNCS9RkGpYEWqT72I6Q3wfTjJh0CWnT7zsdJqI2ZKQh2kUc VO+VuUmPyLLTuCjv3Gcq2fQHd5OVkyme96OuEqnTXv+XN2lpRHuYRJe1I5xyRsYL b07cAYMmuMThcDRI0pgNw3oSLmtexZbxGP5ed5VGxAb/UAJro0RJM9rDInXGdsk2 aZX3iyAYOebsVHNYZvySTtm740e2hN0Zx4JxkYXFiUceMaPY1fSkvINbEu5FZSpv g== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id esekzu_yM_H8; Thu, 27 Jun 2024 20:00:13 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98Ym1WZYzll9br; Thu, 27 Jun 2024 20:00:11 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , "James E.J. Bottomley" , Keoseong Park Subject: [PATCH v2 1/7] scsi: ufs: Declare ufshcd_mcq_poll_cqe_lock() once Date: Thu, 27 Jun 2024 12:58:27 -0700 Message-ID: <20240627195918.2709502-2-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ufshcd_mcq_poll_cqe_lock() is declared in include/ufs/ufshcd.h and also in drivers/ufs/core/ufshcd-priv.h. Remove the declaration from the latter file. Reviewed-by: Avri Altman Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd-priv.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f42d99ce5bf1..0bce72848402 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -72,8 +72,6 @@ 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 Thu Jun 27 19:58:28 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: 808621 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 463B060EC4 for ; Thu, 27 Jun 2024 20:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518438; cv=none; b=jjLCpJR+2XoC5cGm1dg7txaOEY60rz8Odww3mX97rwJU2vt3p7y3ZJHwFBQqXwRfLFZ8yOpqHmTUnH3T1SkbKX41J9mVeYofrXTWEPOxA/NdFteaCw8oCpclu7u8qT2a3D2JJ/nFLCXZm+cIx2iNiKQJHemJfYnXjuOjizck7SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518438; c=relaxed/simple; bh=OzUnDbW2Ip7NyHgx9vapownVMX9ahCU+cLyKOblQawo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cK34Ys/PbtUH5FeArpr2TzWwxgPaRxkmsW3E2zKaagYkOgdmKC7QFkOQK5ZmpxaoY0e/ChViMhA0iRiD8IWYBF1jPb3s/PIRi/Kvu1Nl0B8tKkO4WJIAHpM2KMjxT1hyTwS6qGjOiuidSQZiUj5jnjvW1LlJwCLxtbiWAnegzXM= 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=4fiFCwVv; arc=none smtp.client-ip=199.89.1.12 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="4fiFCwVv" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98ZC4pXczll9br; Thu, 27 Jun 2024 20:00: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=1719518426; x=1722110427; bh=H5nX+ Fu52eYaDdMq/RElQVofF9VNH/yW0Kdtl+ikNmo=; b=4fiFCwVvNgZMU1d03e2pL df17Lw9vVoxV5oWaSTv0kXVeyvYZgdXacERAFlin+0IPtj40buFnpeO4SyZErmTj d7sQg4Du/NiZydvv8oyQjAz2zjKYwKnBFcVn39ukx4M43XOouy9JCyxdzVB07xxN idRHG4orKEJMsImDmOXX36L4fFV+Dn3T8C6/s1gfIITVYKi0dTf+4i4xtSI0EvZe R5uD/RHnPcfQtt6sAnIGJY07tsropxDSbI5ix29BxzDrVhIZxs2zP3eCGNZGMaVI UDLhks/QUlWV6ezBcwNn0egB8fix8o4Q+k1AKGZJkoRmHjZH6/6sUTPSK/ccmB9a w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id JsFs3SftKrOK; Thu, 27 Jun 2024 20:00:26 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98Yx3zB8zlgMVW; Thu, 27 Jun 2024 20:00:21 +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 , "James E.J. Bottomley" , Peter Wang , Andrew Halaney , Bean Huo , Minwoo Im , Maramaina Naresh , Akinobu Mita Subject: [PATCH v2 2/7] scsi: ufs: Initialize struct uic_command once Date: Thu, 27 Jun 2024 12:58:28 -0700 Message-ID: <20240627195918.2709502-3-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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 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 Thu Jun 27 19:58:29 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: 808049 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 628D561FCE for ; Thu, 27 Jun 2024 20:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518437; cv=none; b=XcgLjtXDfoJYq4Yl4lu0xvBPlSARc8V6qWGhK2azr56IL/jskhikbbGxBsxSEC3eY/6z6sUaRMgInKGzbrklYwkoGcf0csZU0M2yVbzsdCdAAHKJT32aK8DOiCwqzES1xyQFGHX9cK5Eh/VxOo8OwNK2RP3/e7VnuKbH0QJHUTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518437; c=relaxed/simple; bh=woWKB4+NiMyb3xgaqZIhovUTbg9vlaHzA1AnoNcHygE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g/9+F+8LlGF+DTJxW73OBDSWrVDIF5LkE0UX6D2XPrvt2JT230R++rVN0RxPMY7GLuyEhK6QrptavX9ruXS4jGYMk14luU+RzBGjEO3WnRO9pmfUUApOK8lTsBcQQTo3eFAN+5G+GZvCg9tnD8b9rCtGRnRZJQ5QgPL6ncOB4iQ= 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+zG3gPb; arc=none smtp.client-ip=199.89.1.12 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+zG3gPb" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98ZC6LzDzlgMVW; Thu, 27 Jun 2024 20:00: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=1719518433; x=1722110434; bh=S2GC7 XC5vzHcPelKpfLA9TpmyUdkePRwe/ZH3qgvo0s=; b=w+zG3gPbvMl/J13KWy4uA li8q8ycZ5dcGeeaW9j3w5DloZmcyBGPKFoIuEl39NqDGpVhM8DtytMqWG/4cSpyi g60WhElAVk1kvOFtF0MTOtmCNZ2UEHeJUMfSa4yOJzscHrd+EC9qkrA/yVBERzD8 RqZEMPX6AIBDIVnkZlBd0gWG4+kJzP6nm/bI85rCZZo190ynRyAxJkruntxkSq9n +MukUcq1wgOfJdG8ihX7fqRzv2LrzpUlethi58w4QQ1PQMuSMiZCnitAe/0Ialee keUPA5JdsKN1E1FKnnx3Z5pG9TbtFnSi/1F5O2nL5w43MU+6dxxmG60qC69GKFaF Q== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id O_CM0OgxGFSV; Thu, 27 Jun 2024 20:00: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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98Z71ybkzll9bp; Thu, 27 Jun 2024 20:00:31 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Manivannan Sadhasivam , "James E.J. Bottomley" , Avri Altman , Peter Wang , Bean Huo Subject: [PATCH v2 3/7] scsi: ufs: Remove two constants Date: Thu, 27 Jun 2024 12:58:29 -0700 Message-ID: <20240627195918.2709502-4-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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 Signed-off-by: Bart Van Assche Reviewed-by: Keoseong Park --- 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 Thu Jun 27 19:58:30 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: 808048 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 EE9CD60EC4 for ; Thu, 27 Jun 2024 20:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518448; cv=none; b=jeCgJaEp6pz54NkZGKcpYslOoVfAcVn5n73BQfdLQrkfPjJ3R8XfuteVa6IXjyh0yNUI1ZPlag/33XDFmiU4CiJQV2luZ9nKgOqOSuElHguoEMvhiOb3xy/2sPEz3q4rhV6DjaNkfE+hpar98rH22EHPMAOIqZx4QA6J3MQcJf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518448; c=relaxed/simple; bh=OgIeVabUMDuPt0iUW7YeN3R0YtW106gGUffenvD5/bc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LpHn0wywTFYCdMePRQyPsjzSRAqMgdmuY6Tnmucb+a5nrbrRU+DTjCXR3Q5UpdpBZIILa3MlqZCqP56J2Hw42Y2T9jZ4ehNvTZBBI40ogh13jRs3/plWPI19qfu2bievJkhAJY+KZwNCAY9pdsttynAk18hNCy9N1QK5i1ZyutA= 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=WLRC6zHU; arc=none smtp.client-ip=199.89.1.12 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="WLRC6zHU" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98ZQ31Zzzll9bw; Thu, 27 Jun 2024 20:00:46 +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=1719518443; x=1722110444; bh=nEIW5 4z3HJ8mnYvQg/ltIEcS9Uayyo0dvbu4ds/IGUw=; b=WLRC6zHUb5C4Ja4i2T4pp x0GwpQXsUUQbpySXm1etZdZwjDeqQRonJVr5Pkrvh50ey9Bjy8BClo42MLV8J5Jv vCZt1kxx1Jh04enyZ+AskDiSV1z0uU/3z6jUf4ET3nSk+RX93MCjyCrPiei+MZ5W tbW6nl1pLJOmjM8BJMoO9tPwNVVgLgdO1BagwVoCzIuVp/nq29NlGDoI5RQ86csi fI0FIVYk4QvUFyYT151CRKRkbL5oHWwxF5hVS2U5bteUAQgkYqaUf9e1UOhXKRyB HaF8hEpZfMFJU6eporuMpd2eyaAXDefnAlogfnz2mYZ7cbsUIVvUeSfJwyIF/AEb w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id ngheBPvyOKnt; Thu, 27 Jun 2024 20:00:43 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98ZK03rxzlgMVW; Thu, 27 Jun 2024 20:00:40 +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 , Manivannan Sadhasivam , Peter Wang , Bean Huo , ChanWoo Lee Subject: [PATCH v2 4/7] scsi: ufs: Rename the MASK_TRANSFER_REQUESTS_SLOTS constant Date: Thu, 27 Jun 2024 12:58:30 -0700 Message-ID: <20240627195918.2709502-5-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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). 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 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 Thu Jun 27 19:58:31 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: 808620 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 0E46D60EC4 for ; Thu, 27 Jun 2024 20:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518454; cv=none; b=EX4U2193VUSaA4yU1r+HBNTNeTq9PRLKJBTJnQteRFDwIY673Z0yf0Lw94In6SdQasv7YsDnXy380/cCt8qyNV4Q1UhGZEN5T5I1G1xZp7pSVNGE9IFlFBpYFRyktjoKQObOosgm5VreV7SpyqV5bEj6Or1nncnFw0x6mxmaiLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518454; c=relaxed/simple; bh=Vy7TJC31+qAvPmUc0HXFjDv3q9dqkheHZXkN+LoWMnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXws/WNlkDG2XKWj5UK5zZUqzdNhfi32DMQQbTeDU0Pav3dnyWZ3jpVXnmKozYhQwGybZfSW9dpDBN4Olr0cF3n/bHj6CofQLqWwvl/Lym2goC4gw4+lzaxiefhCHlccRDnN94y7Z+MyhSjtE6vXjjYBpkJCmJ6Tlvz9YJbMVmo= 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=bVx2Bwe8; arc=none smtp.client-ip=199.89.1.12 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="bVx2Bwe8" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98ZX5kfDzll9by; Thu, 27 Jun 2024 20:00:52 +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=1719518449; x=1722110450; bh=OEU2i A1vTWVGJCG8cceZo/ban5Jrc6fevDW7B5J5uh4=; b=bVx2Bwe85n57ikGgEc+WV RoIy1spuIuHvPEIPHM1Jqv8yDiqLDsLPVNoC7hhqBeFrZ1WXjV2aOxegOu5I6/WH tQvgu+4urYMTRqXVPjQS97nYCnXgw4AlUBVaGngJ8c7rL2Ybduzs3tWfFcGxRd74 +/vJXbl0B43CIqPiUDMWfHsZUR9FBm8+/VvyM+iH+VLbOkPjXHEFfZKzG5NmH0hT 84OXKsVSxwI+zeEEbn0VQ03ckUIKRq2z5FJyLBK0hU5djO1JVA2p2RhZQIFMqDxi 2MMuRINEyyABXSU2Z8wgPSDFbWLTRTVHcg2l1Ut+iuO8+M6mnRB+ZlbZRICUl6+p g== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id 6HV3x3S-Dwkb; Thu, 27 Jun 2024 20:00: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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98ZR4GC5zll9bp; Thu, 27 Jun 2024 20:00:47 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Can Guo , "James E.J. Bottomley" , Avri Altman , Manivannan Sadhasivam , Peter Wang , Bean Huo Subject: [PATCH v2 5/7] scsi: ufs: Initialize hba->reserved_slot earlier Date: Thu, 27 Jun 2024 12:58:31 -0700 Message-ID: <20240627195918.2709502-6-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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 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 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 Thu Jun 27 19:58:32 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: 808047 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 284B460EC4 for ; Thu, 27 Jun 2024 20:01:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518467; cv=none; b=r8TPOgUYG7EBNwcxrdYniTwqjyqE1jhLJDDcfgkeNvLCS8yHIaoFN/XD0o4qPBer1a7IRM4W/ETne6IQ17bSMJtHgfeuthe8UddSm6wmcB16qTXObL+yHtuWEbr4NQ25AjqU1Hgdn6q3c2s5CexEntzbYYjECIi2Co3NfcJ6v7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518467; c=relaxed/simple; bh=ofG2i6iZjxZz0CkQth4444QwyMEJ0F990W50wJOL67U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AQHp3NkQOiNufL11tgQCUYDiK5/rkqO1f7V+4C+hPAZubBbHOTrt+2yt50RHvEdA5r3+GGHssDkFWP9A0gkDo3LTjPzSfUA2n04VjDqPdUJ9cDKwndJXRLXNltdR9wy+WgSWIocyi5sZzxdoNLuSLA+LNSEnqxlAYNTn6kU27i4= 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=MVc/Ac1q; arc=none smtp.client-ip=199.89.1.12 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="MVc/Ac1q" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98Zn56LQzll9bv; Thu, 27 Jun 2024 20:01:05 +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=1719518460; x=1722110461; bh=Yhd76 0WXkoDafpSFoN/9yIHF3/TTwYo+cWGDdf2LbBU=; b=MVc/Ac1qsL2+5KLnd/C2y 7BYm2TeN2UoTDLn0Sz1/Rn8ro0eXvMBupRS1ctRrCGXMxr1V7gYXQ1n7BpijsG7g atJ90hT5Nx+bqhrW0Df22N0c0ldtf1DprFRfEdYi3DxQPGwMWw5fE5qTCsfE2dK/ YZScC2XM86o8PMGl4xDQVs5OqFEE8YS/J27VxJxbNmIJ1UgLVg7M+iu21B7zGz1/ 8YBNe10yNyIfLa4bqwbFgIqlXeKYaZG629+v08P62xalCVQTsomBK9WU+hOXMrIl 0gwxRx/vtLl928W8taZWR1Ci1WBgUUeqsSh1Gib5Mt6lilVOiMB0DW50q3etDhU0 A== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id Y2fgNvXxoVjk; Thu, 27 Jun 2024 20:01:00 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98Zd3gLQzlgMVW; Thu, 27 Jun 2024 20:00:57 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , "James E.J. Bottomley" , Minwoo Im , Peter Wang , Stanley Jhu , ChanWoo Lee , Rohit Ner , "Bao D. Nguyen" , Yang Li , Keoseong Park , Avri Altman Subject: [PATCH v2 6/7] scsi: ufs: Inline ufshcd_mcq_vops_get_hba_mac() Date: Thu, 27 Jun 2024 12:58:32 -0700 Message-ID: <20240627195918.2709502-7-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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(). 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 0bce72848402..fb4457a84d11 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -253,14 +253,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 Thu Jun 27 19:58:33 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: 808619 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (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 296E42139AC for ; Thu, 27 Jun 2024 20:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518484; cv=none; b=jJCAvBUbX6z5erLw7DA3yPpsu8VWdJ2oCJnyxQz+ObYtszsdxL05bYGhlNOcwXN6rV/1/PUrFb/fBp5hXLTX/jzt9DDqIC1NbY3Mx5fJUswNHThuzatAf9V2V1Qdkwg+kHj9AqgBxqXIoiQs7rlP1e7NHoTI57hXXAS77s/V018= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719518484; c=relaxed/simple; bh=mI/VLaLXE+ikgj0plpNTsJl5hjqAMj/p67no7inxiy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r+Tt9wR/28QTuU7A4uvDM8EDdBSFW46TiLGT9ofFDSThRDpDX+Xt5WT5/DcBkiXiu+0fGMJu29iZnVyGjFu5KzWY+1tDYi73IUdDHwZgFNCUhOJpZ+dAp6mlhK0nOCuPxXA92KmjG1SxYAJQ6ciF+YWTUrHAOsvZH4loosjzhj4= 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=wd3TOzrP; arc=none smtp.client-ip=199.89.1.12 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="wd3TOzrP" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W98b64f3Szll9bw; Thu, 27 Jun 2024 20:01:22 +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=1719518475; x=1722110476; bh=LLAf6 j958tUPL7FLJ5lCn3fYqs8gcr/tbTW1Lg3olrA=; b=wd3TOzrPKm5dxHBT7PxxR vqzDJFJWZ4Lo4L3O1mb2KBGYH5UymWK6pFAVVOWzTdSqp929s1BRDqZI6tt0lsN7 +AKL483+MPMnL4SyqY/ApP3JGjJ/kv+wu1v7wG0/zVoW7LPjXTK1417ctvxljDP0 Vwmn37Z4mjCbFqp/GjMhWONYGn2GOStlQpMZvOCmgxGyXfHiXsgq2CNUu6TEv2zy 1K/JMsAnjKlhhqCBRBisOdAcfyHHYFj3eZKizrd6iLfdrFd5mhbJu/wMuaEMgMGH 0aL0fpFAniBEUmLGFVu0Qfs1bogFD8T+Szr/d+1DnMgrul2QX3KXMuWiOvJs2dD8 w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id UOgpwT4Xyu_J; Thu, 27 Jun 2024 20:01:15 +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 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W98Zv5B55zll9bx; Thu, 27 Jun 2024 20:01:11 +0000 (UTC) From: Bart Van Assche To: "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Daejun Park , "James E.J. Bottomley" , Peter Wang , Minwoo Im , Stanley Jhu , ChanWoo Lee , Yang Li , "Bao D. Nguyen" , Avri Altman , Manivannan Sadhasivam , Maramaina Naresh , Akinobu Mita , Bean Huo Subject: [PATCH v2 7/7] scsi: ufs: Make .get_hba_mac() optional Date: Thu, 27 Jun 2024 12:58:33 -0700 Message-ID: <20240627195918.2709502-8-bvanassche@acm.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240627195918.2709502-1-bvanassche@acm.org> References: <20240627195918.2709502-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: Daejun Park Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufs-mcq.c | 15 +++++++++------ include/ufs/ufshcd.h | 4 +++- include/ufs/ufshci.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c index 0482c7a1e419..f4cc4b0676f7 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; diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index d4d63507d090..d32637d267f3 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,