From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796345126; b=SKMDThDy8S0FkNburZO3UXt4Y/fN7MHf2binZICJiYb0hyPf6C0KYsWze+j2D/M+QknV rwmv2Xq30oJRG52FbwCZbMevvFA+cuufmKouecgDSjzhYywAAgMMt+my88HRE2Y0QhEMG bdEPx8IG60vZQOMJKDC+Lu1sje2Q1AFvPCRftkIjS9NwMIIvnuDiS8k/PzQ86v1DJddDT 8wva0H/buRuYC8HmEXZ1TlAYNRWTrPCu44rLBjfp5g34SLXuNDzlB1vmovPYsC/uGzl/G rZwUfj40ouZHjXHxiKUfE9WAbGddzZDqQlftwIzVgVF6PtC73DBVRB+yjTYiLU4g8PQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796345126; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:X-Google-Original-From:Date:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=vxePQlhuO/XBwz/Sg6zyCj4JUVJUZSEHwy89HxcysVo=; b=dQoxsLG2v611YzJTRMFiRBwvTz/f+S6sFLLbjp3qtAj0/lfWW0rxPli/I0XDrnF7YzuL tU07NOtcD0wpjvDlhirTp+jMwcprl7xc4heehsYq/Bq7eOw4d6YkCmGLLEXspjyQMjce6 w9RNRqlQgcfd8qZKqMaFayRJnhhO0SB4IKuXuCOf4uwGiRN1gmCIXdqEDuUDIO9ztTr2k TbMiTkoavdfCXwE5vCKl3gRugninWJXPqFcn3ASrdiUvH75VTUiwuD0EA62135Lcp3Zec XTRtyYyTE28Zdtbc9CYYkcZ/42n7AdTdUlL+zS/8Ot53jP9KdwXEmqMPK31uV9XuoDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=y22zOXze; arc=none smtp.remote-ip=209.85.214.174 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA26B606A32D for ; Fri, 4 Dec 2026 00:45:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CA26B606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=y22zOXze Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2f0458cc9easo4447015ad.3 for ; Thu, 03 Dec 2026 16:45:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796345125; x=1796949925; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:date :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=vxePQlhuO/XBwz/Sg6zyCj4JUVJUZSEHwy89HxcysVo=; b=y22zOXzeRxeYl7/HPlBPGAy97ZpPfxLX8R95zTpYzpTRZ1IVWE4MpicqYBMKuesjI6 WPh3xIBl906VdEn1p4TGKQA8X4dyYRCm6iXiKJiyZH5EespAfgka5oIKLPxVxj4g3E/y Yz9N/SixU0a6ZBVi5POxSmx7xQ1GV5auFrasF/UFlDovJ+qeCn/Qon7jPxmCiLnB2f8s IWhwVBe6vjvdSD+xunK/p0EeaceQ2DBQbpWBq5dtGfnO7lkuQ1OeDPY/j72GB4o5bsOH 66wRR4IzV/QUlSBPAXznM4mzMt5l4R9ZGntOFn4HyCmfkZRbcGsTk7TyECxO5IO3v9q+ QlJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796345125; x=1796949925; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:date :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=vxePQlhuO/XBwz/Sg6zyCj4JUVJUZSEHwy89HxcysVo=; b=NNteyvwk9hp9BuwCye7CDpSEILsjRSzLc1NZT2JWplM+K17hIlxy2Uj43GCfT4ce9/ JsmRMDAWYxGUGeXUeZQ2ujJfXeQJmaPjKhxM6/A8xZUMrbCMGlN5rCxh5IUjyyyIryUS tJ5Nih1R7OK+RNCqmnsLPyB1QcXXUjvfnmknK28nBVnN0aH3FvisKEiZYrUSeVGD2VmY MJXrklkum8PoL7OZ/FO0TStwlRmXFDCwspGhexbJl4o4frBFO7R13lInElclN85JPOI4 SeUyu3MuWvRsYzxPQdpx8O2mMuS+FYzkEF9WO+C1N+Sl1E7gd6I75tIMd3o3LvLHukRZ 9vug== X-Forwarded-Encrypted: i=1; AL+hErEHWv2+mYetR48u8whA+kvkvkdX8ZiF9zrzRZHhL7+n7ezDXoCBkJzUfwOGqLjj89FaoKSL6Fy/oqo=@vger.kernel.org X-Gm-Message-State: APuU4Z+Ffb22CWMJaLnC9rLB6nfkC6qgBVJ4EYkLlztw0zAYohGdu6sX H9w6TJc4/vJhqee2HJlpdz6joegYhVi+2aAP/NU9ah8h9GB57lx4ePWR X-Gm-Gg: AZFdTZcZvbyXxNW9Tub47Cjp7NUq7zdCOKHmQHPF/kwT4XcN7o9LMRe4gJgOx0f1LB/ haVeU/kP5hL3mhowTv1K7TiNeomIjFdG57NIVYzlO7i3+fR/rrTjvQJ+GMBm+VRTmRZw2Yr9LWY 5+kg6F1aANOUNcX5MuXDUP1d+qEMnEfI6Fq9SCJ8k/741OdUbkamgmMcQkSyRDjq2bEbLWaU9fh dP5yr+57KyV7aQ9J5Rd9servtAVdmsJdsVfwHuSSYyCyzPZ94YNXDtOKVHfAYg0AOuklGMJ0YDv 9wRJ6ItUINutcVY9qFN96+FZgteshTrR7bnkB3I/3oJy3+Hhxm3IT1Tc0MPIoZKjWvKhMm2Ardr TDtG9gr11js/wFVF+EiyJjWfeYW34Qio1unBeqkjxQcC4/K3hU/sOCfzsV/b0+pFi2KwOgeYSX0 v7IH+lJjtv+PlbRZKuKstV09NVdAUv8Ky4Gsop0qNYAL+NVctjFRjRNlZeXJKuwWE1zqfUPHq6A i7spHqhTgsZ8HKhVe01vMyYl1uDEOKvPJHcdG5E7p3og/hw4PYiTaVdW2Lf8qTdxtLajt3SyB3C okVXE5e6Gnu4TteqtE6zt2wYzA== X-Received: by 2002:a17:902:f710:b0:2e2:dfe4:adab with SMTP id d9443c01a7336-2f1ba148d38mr2570565ad.10.1796345124920; Thu, 03 Dec 2026 16:45:24 -0800 (PST) Received: from cxlqual ([220.120.90.131]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f1b7940772sm2051485ad.48.2026.12.03.16.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 16:45:24 -0800 (PST) From: Anisa Su X-Google-Original-From: Anisa Su Date: Fri, 4 Dec 2026 09:47:18 +0900 To: sashiko-reviews@lists.linux.dev Cc: Anisa Su , linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev Subject: Re: [PATCH v1 04/14] cxl/mem: Introduce DC event handlers Message-ID: References: <20261104230445.66625-1-anisa.su@samsung.com> <20261104230445.66625-5-anisa.su@samsung.com> X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Nov 04, 2026 at 11:18:43PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: > - [Medium] cxl/mem: incomplete chain abort on staging failure in handle_dcd_chain_event() Fixed, see below. > - [Medium] cxl/mem: missing chain abort in cxl_handle_dcd_event_records() False Positive, see below > -- > > commit 5ef1f10166c3a30ee58534de97a6b9ec5412cf04 > Author: Ira Weiny > > cxl/mem: Introduce DC event handlers > > This commit adds the event handling skeleton for Dynamic Capacity (DC) Add > and Release event chains in the CXL mailbox driver. Chained records with the > CXL_DCD_EVENT_MORE flag set are staged in mds->dc_chain until the closing > record arrives, at which point Add chains are refused with an empty response > and Release chains are acknowledged. > > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > > index 13a68f5cef692..3acf5ace48dbc 100644 > > --- a/drivers/cxl/core/mbox.c > > +++ b/drivers/cxl/core/mbox.c > [ ... ] > > +/* > > + * Drop the open chain. An add chain is refused with an empty response so > > + * the device can reclaim the offered capacity; a release chain is simply > > + * dropped, the capacity stays with the host and the device may retry. > > + */ > > +static void cxl_dc_chain_abort(struct cxl_memdev_state *mds) > > +{ > > + struct cxl_dc_event_chain *chain = &mds->dc_chain; > > + struct device *dev = mds->cxlds.dev; > > + > > + if (chain->event_type == DCD_ADD_CAPACITY && > > + cxl_send_dc_response(mds, CXL_MBOX_OP_ADD_DC_RESPONSE, > > + &chain->pending_extents, 0)) > > + dev_dbg(dev, "Failed to refuse add chain\n"); > > + > > + clear_pending_extents(mds); > > +} > > + > > +static int stage_pending_extent(struct list_head *pending, > > + struct cxl_extent *to_add) > > +{ > > + struct cxl_extent_list_node *node = kzalloc(sizeof(*node), GFP_KERNEL); > > + struct cxl_extent *extent; > > + > > + if (!node) > > + return -ENOMEM; > > + extent = kmemdup(to_add, sizeof(*extent), GFP_KERNEL); > > + if (!extent) { > > + kfree(node); > > + return -ENOMEM; > > + } > > + > > + node->extent = extent; > > + list_add_tail(&node->list, pending); > > + return 0; > > +} > > + > > +static int handle_dcd_chain_event(struct cxl_memdev_state *mds, > > + struct cxl_event_dcd *event) > > +{ > > + struct cxl_dc_event_chain *chain = &mds->dc_chain; > > + struct device *dev = mds->cxlds.dev; > > + int rc; > > + > > + /* Chained records share one event type (CXL r4.0 Table 8-229) */ > > + if (list_empty(&chain->pending_extents)) { > > + chain->event_type = event->event_type; > > + } else if (chain->event_type != event->event_type) { > > + dev_warn_ratelimited(dev, "DC %s record inside an open %s chain; dropping the chain\n", > > + cxl_dcd_evt_type_str(event->event_type), > > + cxl_dcd_evt_type_str(chain->event_type)); > > + cxl_dc_chain_abort(mds); > > + chain->event_type = event->event_type; > > + } > > + > > + rc = stage_pending_extent(&chain->pending_extents, &event->extent); > > + if (rc) { > > + cxl_dc_chain_abort(mds); > > + return rc; > > + } > > [Severity: Medium] > If stage_pending_extent() fails with -ENOMEM on a non-terminal record in a > chain (where event->flags has CXL_DCD_EVENT_MORE set), what prevents the > remaining records of that aborted chain from being processed as a new chain? > Fixed in v2. If stage_pending_extent() fails with -ENOMEM, mark the entire chain with a flag to discard. Add bool discard to struct cxl_dc_event_chain: + * @discard: a record failed to stage; refuse the chain when it closes ... struct cxl_dc_event_chain { struct list_head pending_extents; u8 event_type; + bool discard; }; Set chain->discard to true if staging fails in handle_dcd_chain_event(): if (chain->discard || stage_pending_extent(&chain->pending_extents, &event->extent)) chain->discard = true; > cxl_dc_chain_abort() sends CXL_MBOX_OP_ADD_DC_RESPONSE (for DCD_ADD_CAPACITY) > and empties chain->pending_extents via clear_pending_extents(). However, > cxl_mem_get_records_log() continues iterating through payload->records[i] and > passing subsequent records of the same chain into > cxl_handle_dcd_event_records() -> handle_dcd_chain_event(). > > Because handle_dcd_chain_event() checks list_empty(&chain->pending_extents) to > determine whether a chain is open, the next record in the aborted chain sees an > empty list and starts staging the remainder of the chain as a fresh operation. > When the closing record (More=0) arrives, a DCD_RELEASE_CAPACITY chain will > send CXL_MBOX_OP_RELEASE_DC for only the trailing subset of extents instead of > dropping the chain, and a DCD_ADD_CAPACITY chain will send a duplicate > CXL_MBOX_OP_ADD_DC_RESPONSE. > > Should struct cxl_dc_event_chain track an aborted state until the closing > record with CXL_DCD_EVENT_MORE cleared is consumed? > > > + > > + if (event->flags & CXL_DCD_EVENT_MORE) { > > + dev_dbg(dev, "more bit set; delay processing of extent\n"); > > + return 0; > > + } > > + > > + /* Nothing is tracked yet: refuse every add, acknowledge every release */ > > + if (event->event_type == DCD_ADD_CAPACITY) > > + rc = cxl_send_dc_response(mds, CXL_MBOX_OP_ADD_DC_RESPONSE, > > + &chain->pending_extents, 0); > > + else > > + rc = cxl_send_dc_response(mds, CXL_MBOX_OP_RELEASE_DC, > > + &chain->pending_extents, > > + list_count_nodes(&chain->pending_extents)); > > + clear_pending_extents(mds); > > + return rc; > > +} > > + > > +static void cxl_handle_dcd_event_records(struct cxl_memdev_state *mds, > > + struct cxl_event_record_raw *raw_rec) > > +{ > > + struct cxl_event_dcd *event = &raw_rec->event.dcd; > > + struct cxl_extent *extent = &event->extent; > > + struct device *dev = mds->cxlds.dev; > > + uuid_t *id = &raw_rec->id; > > + int rc; > > + > > + if (!uuid_equal(id, &CXL_EVENT_DC_EVENT_UUID)) > > + return; > > + > > + dev_dbg(dev, "DCD event %s : DPA:%#llx LEN:%#llx\n", > > + cxl_dcd_evt_type_str(event->event_type), > > + le64_to_cpu(extent->start_dpa), le64_to_cpu(extent->length)); > > + > > + switch (event->event_type) { > > + case DCD_ADD_CAPACITY: > > + case DCD_RELEASE_CAPACITY: > > + rc = handle_dcd_chain_event(mds, event); > > + break; > > + case DCD_FORCED_CAPACITY_RELEASE: > > + dev_err_ratelimited(dev, "Forced release event ignored.\n"); > > + rc = 0; > > + break; > > + case DCD_REGION_CONFIGURATION_UPDATED: > > + dev_dbg(dev, "Region configuration updated event ignored.\n"); > > + rc = 0; > > + break; > > + default: > > + rc = -EINVAL; > > + break; > > + } > > [Severity: Medium] > What happens if a DCD_FORCED_CAPACITY_RELEASE, > DCD_REGION_CONFIGURATION_UPDATED, unknown event_type, or non-DC UUID record > arrives in the DCD log while mds->dc_chain.pending_extents is non-empty? > The spec does not permit this. Per r4.0 Table 8-229, records grouped together by "More=1" shall be continuous... "with no unrelated records between them, and shall contain the same DC event type" No need to fix unless a real device with this issue emerges. > Currently, the check for an open chain is only performed inside > handle_dcd_chain_event(), which is only called for DCD_ADD_CAPACITY and > DCD_RELEASE_CAPACITY. If another event record arrives in the middle of an open > chain, cxl_handle_dcd_event_records() does not call cxl_dc_chain_abort(mds). > > As a result, an interrupted Add chain is not refused when broken by the > intervening record, and if the next chain shares the same event_type as the > interrupted one, handle_dcd_chain_event() sees chain->event_type == > event->event_type and merges the stale extents from the broken chain into the > new chain. > > Should cxl_handle_dcd_event_records() abort any open chain when receiving > these non-chain records? > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261104230445.66625-1-anisa.su@samsung.com?part=4