* [PATCH 0/1] cxl/mem: Fix for the index of Clear Event Record Handle
@ 2024-03-15 10:53 Yuquan Wang
2024-03-15 10:53 ` [PATCH 1/1] " Yuquan Wang
0 siblings, 1 reply; 3+ messages in thread
From: Yuquan Wang @ 2024-03-15 10:53 UTC (permalink / raw)
To: ira.weiny, jonathan.cameron, dan.j.williams
Cc: linux-cxl, linux-kernel, qemu-devel, chenbaozi, Yuquan Wang
This is a simple fix for the index of 'Clear Event Record' Handle. The
print content of dev_dbg from Clear Event Records mailbox command would
report the handle of the next record to clear not the current one.
The problem was found when I was doing the debug of CXL Event Error on
Qemu. I injected an individual event through QMP
'cxl-inject-general-media-event':
{ "execute": "cxl-inject-general-media-event",
"arguments": {
"path": "/machine/peripheral/cxl-mem0",
"log": "informational",
"flags": 1,
"dpa": 1000,
"descriptor": 3,
"type": 3,
"transaction-type": 192,
"channel": 3,
"device": 5,
"component-id": "iras mem"
}}
Then the kernel printed:
[ 1639.106181] cxl_pci 0000:0d:00.0: Event log '0': Clearing 0
However, the line 36 in 'hw/cxl/cxl-events.c': log->next_handle = 1;
It will set the actual handle value of injected event to '1'.
With this fix, the kernel will print:
[ 122.456750] cxl_pci 0000:0d:00.0: Event log '0': Clearing 1
which is in line with the simulated value in Qemu.
Yuquan Wang (1):
cxl/mem: Fix for the index of Clear Event Record Handle
drivers/cxl/core/mbox.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] cxl/mem: Fix for the index of Clear Event Record Handle
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
2024-03-15 17:53 ` Dan Williams
0 siblings, 1 reply; 3+ messages in thread
From: Yuquan Wang @ 2024-03-15 10:53 UTC (permalink / raw)
To: ira.weiny, jonathan.cameron, dan.j.williams
Cc: linux-cxl, linux-kernel, qemu-devel, chenbaozi, Yuquan Wang
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] cxl/mem: Fix for the index of Clear Event Record Handle
2024-03-15 10:53 ` [PATCH 1/1] " Yuquan Wang
@ 2024-03-15 17:53 ` Dan Williams
0 siblings, 0 replies; 3+ messages in thread
From: Dan Williams @ 2024-03-15 17:53 UTC (permalink / raw)
To: Yuquan Wang, ira.weiny, jonathan.cameron, dan.j.williams
Cc: linux-cxl, linux-kernel, qemu-devel, chenbaozi, Yuquan Wang
Yuquan Wang wrote:
> 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]));
Couldn't this patch be much smaller by just changing this to "i - 1",
because from the description the only problem is the dev_dbg()
statement, so just fix that.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-15 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/1] " Yuquan Wang
2024-03-15 17:53 ` Dan Williams
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 NNTP newsgroup(s).