Message ID | e4c530ac9c073eb753a98a052216d58a571799e4.1674101475.git.alison.schofield@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | cxl: CXL Inject & Clear Poison | expand |
On Wed, 18 Jan 2023 21:00:20 -0800 alison.schofield@intel.com wrote: > From: Alison Schofield <alison.schofield@intel.com> > > Prior to poison inject support, the mock of 'Get Poison List' > returned a poison list containing a single mocked error record. > > Now, following the addition of poison inject and clear support, > use the mock_poison_list[] as the source of records for 'Get > Poison List' requests. > > This supports confirmation of inject and clear poison commands. > > Signed-off-by: Alison Schofield <alison.schofield@intel.com> A comment inline. Either way I'm fine with this. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > tools/testing/cxl/test/mem.c | 56 ++++++++++++++++++++++++------------ > 1 file changed, 38 insertions(+), 18 deletions(-) > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > index bb0be9fe3fe9..14d74bfb3124 100644 > --- a/tools/testing/cxl/test/mem.c > +++ b/tools/testing/cxl/test/mem.c > @@ -582,31 +582,51 @@ static struct mock_poison { > u64 dpa; > } mock_poison_list[MOCK_INJECT_TEST_MAX]; > > +static struct cxl_mbox_poison_payload_out > +*cxl_get_injected_po(struct cxl_dev_state *cxlds, u64 offset, u64 length) > +{ > + struct cxl_mbox_poison_payload_out *po; > + int nr_records = 0; > + u64 dpa; > + > + po = kzalloc(struct_size(po, record, MOCK_INJECT_DEV_MAX), GFP_KERNEL); > + if (!po) > + return NULL; > + > + for (int i = 0; i < MOCK_INJECT_TEST_MAX; i++) { > + if (mock_poison_list[i].cxlds != cxlds) > + continue; > + if (mock_poison_list[i].dpa < offset || > + mock_poison_list[i].dpa > offset + length - 1) I was thinking that we could move this to the add side of things, but perhaps it actually makes sense in both code paths? > + continue; > + > + dpa = mock_poison_list[i].dpa + CXL_POISON_SOURCE_INJECTED; > + po->record[nr_records].address = cpu_to_le64(dpa); > + po->record[nr_records].length = cpu_to_le32(1); > + nr_records++; > + if (nr_records == MOCK_INJECT_DEV_MAX) > + break; > + } > + > + /* Always return count, even when zero */ > + po->count = cpu_to_le16(nr_records); > + > + return po; > +} > +
On Mon, Jan 23, 2023 at 03:16:53PM +0000, Jonathan Cameron wrote: > On Wed, 18 Jan 2023 21:00:20 -0800 > alison.schofield@intel.com wrote: > > > From: Alison Schofield <alison.schofield@intel.com> > > > > Prior to poison inject support, the mock of 'Get Poison List' > > returned a poison list containing a single mocked error record. > > > > Now, following the addition of poison inject and clear support, > > use the mock_poison_list[] as the source of records for 'Get > > Poison List' requests. > > > > This supports confirmation of inject and clear poison commands. > > > > Signed-off-by: Alison Schofield <alison.schofield@intel.com> > A comment inline. Either way I'm fine with this. replied below... > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > > > --- > > tools/testing/cxl/test/mem.c | 56 ++++++++++++++++++++++++------------ > > 1 file changed, 38 insertions(+), 18 deletions(-) > > > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > > index bb0be9fe3fe9..14d74bfb3124 100644 > > --- a/tools/testing/cxl/test/mem.c > > +++ b/tools/testing/cxl/test/mem.c > > @@ -582,31 +582,51 @@ static struct mock_poison { > > u64 dpa; > > } mock_poison_list[MOCK_INJECT_TEST_MAX]; > > > > +static struct cxl_mbox_poison_payload_out > > +*cxl_get_injected_po(struct cxl_dev_state *cxlds, u64 offset, u64 length) > > +{ > > + struct cxl_mbox_poison_payload_out *po; > > + int nr_records = 0; > > + u64 dpa; > > + > > + po = kzalloc(struct_size(po, record, MOCK_INJECT_DEV_MAX), GFP_KERNEL); > > + if (!po) > > + return NULL; > > + > > + for (int i = 0; i < MOCK_INJECT_TEST_MAX; i++) { > > + if (mock_poison_list[i].cxlds != cxlds) > > + continue; > > + if (mock_poison_list[i].dpa < offset || > > + mock_poison_list[i].dpa > offset + length - 1) > > I was thinking that we could move this to the add side of things, but > perhaps it actually makes sense in both code paths? > I'm not understanding what can be done in the add side wrt the above. The 'add side' is the inject, and it can only inject one 64byte length. Here, mocking get-poison-list, we look at each DPA stored for cxlds, and return it if it's in the offset/lenght requested. Am I missing something? Alison > > + continue; > > + > > + dpa = mock_poison_list[i].dpa + CXL_POISON_SOURCE_INJECTED; > > + po->record[nr_records].address = cpu_to_le64(dpa); > > + po->record[nr_records].length = cpu_to_le32(1); > > + nr_records++; > > + if (nr_records == MOCK_INJECT_DEV_MAX) > > + break; > > + } > > + > > + /* Always return count, even when zero */ > > + po->count = cpu_to_le16(nr_records); > > + > > + return po; > > +} > > + >
On Mon, 23 Jan 2023 16:24:07 -0800 Alison Schofield <alison.schofield@intel.com> wrote: > On Mon, Jan 23, 2023 at 03:16:53PM +0000, Jonathan Cameron wrote: > > On Wed, 18 Jan 2023 21:00:20 -0800 > > alison.schofield@intel.com wrote: > > > > > From: Alison Schofield <alison.schofield@intel.com> > > > > > > Prior to poison inject support, the mock of 'Get Poison List' > > > returned a poison list containing a single mocked error record. > > > > > > Now, following the addition of poison inject and clear support, > > > use the mock_poison_list[] as the source of records for 'Get > > > Poison List' requests. > > > > > > This supports confirmation of inject and clear poison commands. > > > > > > Signed-off-by: Alison Schofield <alison.schofield@intel.com> > > A comment inline. Either way I'm fine with this. > > replied below... > > > > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > > > > > --- > > > tools/testing/cxl/test/mem.c | 56 ++++++++++++++++++++++++------------ > > > 1 file changed, 38 insertions(+), 18 deletions(-) > > > > > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > > > index bb0be9fe3fe9..14d74bfb3124 100644 > > > --- a/tools/testing/cxl/test/mem.c > > > +++ b/tools/testing/cxl/test/mem.c > > > @@ -582,31 +582,51 @@ static struct mock_poison { > > > u64 dpa; > > > } mock_poison_list[MOCK_INJECT_TEST_MAX]; > > > > > > +static struct cxl_mbox_poison_payload_out > > > +*cxl_get_injected_po(struct cxl_dev_state *cxlds, u64 offset, u64 length) > > > +{ > > > + struct cxl_mbox_poison_payload_out *po; > > > + int nr_records = 0; > > > + u64 dpa; > > > + > > > + po = kzalloc(struct_size(po, record, MOCK_INJECT_DEV_MAX), GFP_KERNEL); > > > + if (!po) > > > + return NULL; > > > + > > > + for (int i = 0; i < MOCK_INJECT_TEST_MAX; i++) { > > > + if (mock_poison_list[i].cxlds != cxlds) > > > + continue; > > > + if (mock_poison_list[i].dpa < offset || > > > + mock_poison_list[i].dpa > offset + length - 1) > > > > I was thinking that we could move this to the add side of things, but > > perhaps it actually makes sense in both code paths? > > > > I'm not understanding what can be done in the add side wrt the above. > > The 'add side' is the inject, and it can only inject one 64byte length. > > Here, mocking get-poison-list, we look at each DPA stored for cxlds, > and return it if it's in the offset/lenght requested. > > Am I missing something? Nope. I clearly hadn't had enough coffee. My comment indeed makes no sense. Jonathan > Alison > > > > + continue; > > > + > > > + dpa = mock_poison_list[i].dpa + CXL_POISON_SOURCE_INJECTED; > > > + po->record[nr_records].address = cpu_to_le64(dpa); > > > + po->record[nr_records].length = cpu_to_le32(1); > > > + nr_records++; > > > + if (nr_records == MOCK_INJECT_DEV_MAX) > > > + break; > > > + } > > > + > > > + /* Always return count, even when zero */ > > > + po->count = cpu_to_le16(nr_records); > > > + > > > + return po; > > > +} > > > + > >
diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index bb0be9fe3fe9..14d74bfb3124 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -582,31 +582,51 @@ static struct mock_poison { u64 dpa; } mock_poison_list[MOCK_INJECT_TEST_MAX]; +static struct cxl_mbox_poison_payload_out +*cxl_get_injected_po(struct cxl_dev_state *cxlds, u64 offset, u64 length) +{ + struct cxl_mbox_poison_payload_out *po; + int nr_records = 0; + u64 dpa; + + po = kzalloc(struct_size(po, record, MOCK_INJECT_DEV_MAX), GFP_KERNEL); + if (!po) + return NULL; + + for (int i = 0; i < MOCK_INJECT_TEST_MAX; i++) { + if (mock_poison_list[i].cxlds != cxlds) + continue; + if (mock_poison_list[i].dpa < offset || + mock_poison_list[i].dpa > offset + length - 1) + continue; + + dpa = mock_poison_list[i].dpa + CXL_POISON_SOURCE_INJECTED; + po->record[nr_records].address = cpu_to_le64(dpa); + po->record[nr_records].length = cpu_to_le32(1); + nr_records++; + if (nr_records == MOCK_INJECT_DEV_MAX) + break; + } + + /* Always return count, even when zero */ + po->count = cpu_to_le16(nr_records); + + return po; +} + static int mock_get_poison(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) { struct cxl_mbox_poison_payload_in *pi = cmd->payload_in; + struct cxl_mbox_poison_payload_out *po; + u64 offset = le64_to_cpu(pi->offset); + u64 length = le64_to_cpu(pi->length); - /* Mock one poison record at pi.offset for 64 bytes */ - struct { - struct cxl_mbox_poison_payload_out po; - struct cxl_poison_record record; - } mock_plist = { - .po = { - .count = cpu_to_le16(1), - }, - .record = { - .length = cpu_to_le32(1), - .address = cpu_to_le64(pi->offset + - CXL_POISON_SOURCE_INJECTED), - }, - }; + po = cxl_get_injected_po(cxlds, offset, length); - if (cmd->size_out < sizeof(mock_plist)) - return -EINVAL; + memcpy(cmd->payload_out, po, struct_size(po, record, po->count)); + cmd->size_out = struct_size(po, record, po->count); - memcpy(cmd->payload_out, &mock_plist, sizeof(mock_plist)); - cmd->size_out = sizeof(mock_plist); return 0; }