From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: <qemu-devel@nongnu.org>, <alison.schofield@intel.com>,
<linux-cxl@vger.kernel.org>, <linuxarm@huawei.com>
Cc: <shiju.jose@huawei.com>,
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
Subject: Re: [RFC PATCH] hw/cxl: Initial poison injection support.
Date: Wed, 22 Jun 2022 11:38:55 +0100 [thread overview]
Message-ID: <20220622113855.00004009@huawei.com> (raw)
In-Reply-To: <20220620173452.000026c5@huawei.com>
> > +/*
> > + * This is very inefficient, but good enough for now!
> > + * Also thed payload will always fit, so no need to handle the MORE flag and
> > + * make this stateful.
> > + */
> > +static ret_code cmd_media_get_poison_list(struct cxl_cmd *cmd,
> > + CXLDeviceState *cxl_dstate,
> > + uint16_t *len)
> > +{
> > + struct get_poison_list_pl {
> > + uint64_t pa;
> > + uint64_t length;
> > + } QEMU_PACKED;
> > +
> > + struct get_poison_list_out_pl {
> > + uint8_t flags;
> > + uint8_t rsvd1;
> > + uint64_t overflow_timestamp;
> > + uint16_t count;
> > + uint8_t rsvd2[0x14];
> > + struct {
> > + uint64_t addr;
> > + uint32_t length;
> > + uint32_t resv;
> > + } QEMU_PACKED records[];
> > + } QEMU_PACKED;
> > +
> > + struct get_poison_list_pl *in = (void *)cmd->payload;
> > + struct get_poison_list_out_pl *out = (void *)cmd->payload;
> > + CXLType3Dev *ct3d = container_of(cxl_dstate, CXLType3Dev, cxl_dstate);
> > + CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d);
> > + uint16_t record_count = 0, i = 0;
> > + uint64_t query_start = in->pa;
> > + uint64_t query_length = in->length;
> > + CXLPoisonList *poison_list;
> > + CXLPoison *ent;
> > + uint16_t out_pl_len;
> > +
> > + poison_list = cvc->get_poison_list(ct3d);
> > +
> > + QLIST_FOREACH(ent, poison_list, node) {
> > + /* Check for no overlap */
> > + if (ent->start >= query_start + query_length ||
> > + ent->start + ent->length <= query_start) {
> > + continue;
> > + }
> > + if (record_count == 256) {
> > + /* For now just return 256 max */
> > + break;
> > + }
> > + record_count++;
> > + }
> > + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]);
> > + assert(out_pl_len > CXL_MAILBOX_MAX_PAYLOAD_SIZE);
* embarrassed cough*. Check is inverted. Naught me tidied up a runtime
check into this but forgot to invert the sense + clearly didn't build
the right tree for final testing.
> > +
> > + memset(out, 0, out_pl_len);
> > + QLIST_FOREACH(ent, poison_list, node) {
> > + uint64_t start, stop;
> > +
> > + /* Check for no overlap */
> > + if (ent->start >= query_start + query_length ||
> > + ent->start + ent->length <= query_start) {
> > + continue;
> > + }
> > + if (i == 256) {
> > + break;
> > + }
> > + /* Deal with overlap */
> > + start = MAX(ent->start & 0xffffffffffffffc0, query_start);
> > + stop = MIN((ent->start & 0xffffffffffffffc0) + ent->length,
> > + query_start + query_length);
> > + out->records[i].addr = start | 0x2; /* internal error */
> > + out->records[i].length = (stop - start) / 64;
> > + i++;
> > + }
> > + out->count = record_count;
> > + *len = out_pl_len;
> > + return CXL_MBOX_SUCCESS;
> > +}
> > +
prev parent reply other threads:[~2022-06-22 10:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 16:20 [RFC PATCH] hw/cxl: Initial poison injection support Jonathan Cameron
2022-06-20 16:34 ` Jonathan Cameron
2022-06-22 10:38 ` Jonathan Cameron [this message]
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=20220622113855.00004009@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shiju.jose@huawei.com \
/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