On Tue, Jun 30, 2026 at 02:11:12PM -0700, Dave Jiang wrote:
>
>
> On 6/25/26 4:04 AM, Anisa Su wrote:
> > A DC_ADD_CAPACITY event can span multiple event records grouped together
> > by the CXL_DCD_EVENT_MORE flag. Extents are staged in the pending list until
> > the last event record ('More'=0) is received, at which point the pending
> > list is processed. If the device opens such a chain (More=1) but never
> > sends the closing record, the staged list sits indefinitely.
> >
> > Add a delayed-work watchdog that, on expiry, refuses the chain with an
> > empty ADD_DC_RESPONSE and drops the staged list.
> >
> > The 20s timeout is a conservative upper bound and may be tightened
> > later. The timeout is purely defensive — the spec does not require it,
> > but prevents issues from a lost mailbox response or a crashed fabric
> > manager.
> >
> > The watchdog bounds how long a chain may stall, but a device could still
> > defeat it by streaming More=1 records faster than the timeout, growing the
> > staged list without bound. Also cap a runtime chain at
> > CXL_DC_MAX_PENDING_EXTENTS and refuse it once exceeded; existing-extent
> > recovery is bounded separately by the device's reported extent count.
> >
> > Signed-off-by: Anisa Su <[email protected]>
>
> Minor comment below in addition to sashiko
>
[snip]
> > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
> > index 4ffa7bd1e5f1..81498d47f309 100644
> > --- a/drivers/cxl/cxlmem.h
> > +++ b/drivers/cxl/cxlmem.h
> > @@ -8,6 +8,8 @@
> > #include <linux/uuid.h>
> > #include <linux/node.h>
> > #include <linux/list.h>
> > +#include <linux/mutex.h>
> > +#include <linux/workqueue.h>
> > #include <cxl/event.h>
> > #include <cxl/mailbox.h>
> > #include "cxl.h"
> > @@ -407,19 +409,33 @@ static inline struct cxl_dev_state
> > *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)
> >
> > /**
> > * struct pending_add_ctx - Staging state for an in-progress
> > - * DCD_ADD_CAPACITY event chain
> > + * DCD_ADD_CAPACITY event
> > chain
> > * @pending_extents: extents received so far in the chain; flushed when
> > - * the chain closes (More=0)
> > + * the chain closes (More=0)
> > * @group: tag group being assembled from the chain
> > + * @timeout_work: watchdog that fires if a chain is opened with
> > + * CXL_DCD_EVENT_MORE but the closing record
> > never arrives
> > + * @lock: serialises updates to the chain state against the watchdog
> > + * @armed: set when a More=1 chain opens; cleared when the chain closes,
> > + * either by a More=0 event record or by the watchdog firing.
> > *
> > * A DCD_ADD_CAPACITY notification can span multiple event records
> > * stitched together by the CXL_DCD_EVENT_MORE flag. Records are staged
> > - * here until the device clears More, at which point the staged batch is
> > - * processed and responded to as a single Add_DC_Response.
> > + * here until an event record with 'More'=0 is received, at which point the
> > + * staged batch is processed and responded to as a single Add_DC_Response.
> > + *
> > + * If a chain is opened (More=1) but the device never sends the closing
> > + * record, the staged list would otherwise sit indefinitely. @timeout_work
> > + * is a defensive watchdog that refuses such a chain with an empty response
> > + * and drops the staged list.
> > */
> > struct pending_add_ctx {
> > struct list_head pending_extents;
> > struct cxl_dc_tag_group *group;
> > + struct delayed_work timeout_work;
> > + struct mutex lock;
> > + unsigned int nr_pending;
>
> Missing kdoc in comment section
>
Added
Thanks,
Anisa
> > + bool armed;
> > };
> >
> > /**
>