Linux-CXL Archive mirror
 help / color / mirror / Atom feed
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
To: ira.weiny@intel.com, jonathan.cameron@huawei.com,
	dan.j.williams@intel.com
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
	qemu-devel@nongnu.org, chenbaozi@phytium.com.cn,
	Yuquan Wang <wangyuquan1236@phytium.com.cn>
Subject: [PATCH 1/1] cxl/mem: Fix for the index of Clear Event Record Handle
Date: Fri, 15 Mar 2024 18:53:36 +0800	[thread overview]
Message-ID: <20240315105336.464156-2-wangyuquan1236@phytium.com.cn> (raw)
In-Reply-To: <20240315105336.464156-1-wangyuquan1236@phytium.com.cn>

The dev_dbg info for Clear Event Records mailbox command would report
the handle of the next record to clear not the current one.

This was because the index 'i' had incremented before printing the
current handle value.

This fix also adjusts the index variable name from 'i' to 'clear_cnt'
which can be easier for developers to distinguish and understand.

Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
---
 drivers/cxl/core/mbox.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 9adda4795eb7..3ca2845ae6aa 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -881,7 +881,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
 	struct cxl_mbox_cmd mbox_cmd;
 	u16 cnt;
 	int rc = 0;
-	int i;
+	int clear_cnt;
 
 	/* Payload size may limit the max handles */
 	if (pl_size > mds->payload_size) {
@@ -908,28 +908,29 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
 	 * Clear Event Records uses u8 for the handle cnt while Get Event
 	 * Record can return up to 0xffff records.
 	 */
-	i = 0;
+	clear_cnt = 0;
 	for (cnt = 0; cnt < total; cnt++) {
 		struct cxl_event_record_raw *raw = &get_pl->records[cnt];
 		struct cxl_event_generic *gen = &raw->event.generic;
 
-		payload->handles[i++] = gen->hdr.handle;
+		payload->handles[clear_cnt] = gen->hdr.handle;
 		dev_dbg(mds->cxlds.dev, "Event log '%d': Clearing %u\n", log,
-			le16_to_cpu(payload->handles[i]));
+			le16_to_cpu(payload->handles[clear_cnt]));
 
-		if (i == max_handles) {
-			payload->nr_recs = i;
+		clear_cnt++;
+		if (clear_cnt == max_handles) {
+			payload->nr_recs = clear_cnt;
 			rc = cxl_internal_send_cmd(mds, &mbox_cmd);
 			if (rc)
 				goto free_pl;
-			i = 0;
+			clear_cnt = 0;
 		}
 	}
 
 	/* Clear what is left if any */
-	if (i) {
-		payload->nr_recs = i;
-		mbox_cmd.size_in = struct_size(payload, handles, i);
+	if (clear_cnt) {
+		payload->nr_recs = clear_cnt;
+		mbox_cmd.size_in = struct_size(payload, handles, clear_cnt);
 		rc = cxl_internal_send_cmd(mds, &mbox_cmd);
 		if (rc)
 			goto free_pl;
-- 
2.34.1


  reply	other threads:[~2024-03-15 10:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 10:53 [PATCH 0/1] cxl/mem: Fix for the index of Clear Event Record Handle Yuquan Wang
2024-03-15 10:53 ` Yuquan Wang [this message]
2024-03-15 17:53   ` [PATCH 1/1] " Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240315105336.464156-2-wangyuquan1236@phytium.com.cn \
    --to=wangyuquan1236@phytium.com.cn \
    --cc=chenbaozi@phytium.com.cn \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).