Skip to content

Commit ea5514e

Browse files
committed
Merge branch 'for-6.19/cxl-misc' into cxl-for-next
- Remove ret_limit race condition in mock_get_event() - Assign overflow_err_count from log->nr_overflow
2 parents b5bea8c + f1840ef commit ea5514e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • tools/testing/cxl/test

tools/testing/cxl/test/mem.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,22 +250,21 @@ static void mes_add_event(struct mock_event_store *mes,
250250
* Vary the number of events returned to simulate events occuring while the
251251
* logs are being read.
252252
*/
253-
static int ret_limit = 0;
253+
static atomic_t event_counter = ATOMIC_INIT(0);
254254

255255
static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd)
256256
{
257257
struct cxl_get_event_payload *pl;
258258
struct mock_event_log *log;
259-
u16 nr_overflow;
259+
int ret_limit;
260260
u8 log_type;
261261
int i;
262262

263263
if (cmd->size_in != sizeof(log_type))
264264
return -EINVAL;
265265

266-
ret_limit = (ret_limit + 1) % CXL_TEST_EVENT_RET_MAX;
267-
if (!ret_limit)
268-
ret_limit = 1;
266+
/* Vary return limit from 1 to CXL_TEST_EVENT_RET_MAX */
267+
ret_limit = (atomic_inc_return(&event_counter) % CXL_TEST_EVENT_RET_MAX) + 1;
269268

270269
if (cmd->size_out < struct_size(pl, records, ret_limit))
271270
return -EINVAL;
@@ -299,7 +298,7 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd)
299298
u64 ns;
300299

301300
pl->flags |= CXL_GET_EVENT_FLAG_OVERFLOW;
302-
pl->overflow_err_count = cpu_to_le16(nr_overflow);
301+
pl->overflow_err_count = cpu_to_le16(log->nr_overflow);
303302
ns = ktime_get_real_ns();
304303
ns -= 5000000000; /* 5s ago */
305304
pl->first_overflow_timestamp = cpu_to_le64(ns);

0 commit comments

Comments
 (0)