From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796336490; b=GMHx0BBvO1akJhGqTEvEMk8kF5hCw9dfsC2Wh7sup83rIy4NUH82i9ptywgwPoaqaOmz 23FFObEmbU6r1tSz6xmQqGqtmjlyeiRofr0PDaTeSLrwnrbAewaIO/nXYaoT9uAVLMcIA 21H9BDvZZYxxik+1CvYU/KTXA1Jq6LM/YpOlZ8KbD8D0XKWv6KvlrxHAvkyiSLvPP0Y8R /Bn4IbSKu5DtsA+n+y24GxwdXxk2NQIgI+cWlN4N5m0pvLzktqSFnSiMJ2xIvrRoGUMgN aY0kMi9rVb4j8MX/zrf9NkO7mDXq0mlM5CJsOhBkvzycvrEc2vuTs7jdYx7YRPkS9ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796336490; 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:In-Reply-To; bh=h5thXo3RAkU0p3gWaKcokQMEUK80fnpYrC44exh3Yh4=; b=UiT3yXxelnWAtamKjBQMQwCwYUE6sqqwcr4BNe6PQtyND6y/RTQkflNqvzskSIWYgwor e/yUNqTv4ucnuuW9w8Ai8yZPfkgBJGgcl8hsRPuz6PvN3Z/HRj5wbd19ZYFllaQmE0QHV XAOv0918AJFLCrgvEm6AB88zEQXJzi5oIQqjrEDIdx3I7cVgmZkPI2/GIjKBulOCKovZ0 hT4Lj9gr+IKmgJaPC1rZ8QXjTicpfqeMxJ5ZX1wyPFoutzgF4V7HiMDOFtLk+0PvvPvDX K67bmaMgo0AK7OE+vLPjn21azn/P3kZLKfu3dnoxWiTayEASzf/WHlLvpHja/hMrXRA== 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=hYMkQ4Rw; arc=none smtp.remote-ip=209.85.216.54 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 CEA30606A322 for ; Thu, 3 Dec 2026 22:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CEA30606A322 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=hYMkQ4Rw Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3b44bdcea8aso983986a91.1 for ; Thu, 03 Dec 2026 14:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796336489; x=1796941289; darn=vger.kernel.org; h=in-reply-to: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=h5thXo3RAkU0p3gWaKcokQMEUK80fnpYrC44exh3Yh4=; b=hYMkQ4RwM03PbjgBENHyCJCI05iyC6ZfOu+NCDjMy/JiKCN/5lSsYaa07iOJ3dR+K6 tHNSq3B6WR4RbGZ5Bo43oAKqCcGZH2YSKgigOGsDMV8Ir4rJGZyCksHPhiZqIBbwSJF5 a18mc1B+cUhdV3encLWJZvvaxIIjryGsHzCP6zCeLmWu8kAQnjJm6lMwZkfQ68vL8R8y TeWMFTXU7QMs65WBAoUyuwA761ZWxDgFfH8n3lkGkiYHItmXT4UdpIpkVW5x/OVTthPX pMLwHd7PI1pmFsUqKu6URKeN7zEL5hGM0WxlfydGxGjR9GTdTsJdrrK/MvMYD4vAiLBV JvFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796336489; x=1796941289; h=in-reply-to: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=h5thXo3RAkU0p3gWaKcokQMEUK80fnpYrC44exh3Yh4=; b=VqjrsMbJefVvl/NMwd415NpRBP5HMS9fgT4YOrKKF7XiN93megBbKkX4LPa7GrwFmv 6axN9akDGksqc/8kviJXFppYj9OBQCkxMclO1ATQylmfZHx+9Njd0gl6NH/+0LctpWeW FDrQvwlZhAIAJ9SyPz+ar1x/53OQbJpHRVPgjmnHjkPHjY5+29AV3RLG4JhL/ezhATEB 3yxOtMjHRk9XWwR0qT2I40KcmfkBNjvu1UmRXPcQjvvnhorgs0yQdu5+o74YC4q7Ey8T Dpt7d28uRnSyUp/CjJ4+M0WIDKJ44ziF4WYI43Ez1g4WhtuopTRVskafpzNGxui9Otvd o3Cw== X-Forwarded-Encrypted: i=1; AL+hErEV5LcbAfz8mfAgRYqg4iLhnZz3Sv2OEsmcDmY/xuZ3RxVjmuvRD9oetSWUtf1uLxKbUWPcb0hZmJKcntI=@vger.kernel.org X-Gm-Message-State: APuU4Z9hrFKpLvDlwxoovNsGrkhFp6ES3/w5Fdfmiz4DpxeU21/7l22M cEmHqqoi2RMLnpo8SXY9igZI4yjBHY5ZLIskkkV/lcy1ZBb7ziibAaMQ X-Gm-Gg: AZFdTZdHRGJEe3YP+vhhHfeHcXCx5GdICO6mKmWCBEL/MWT+Xyr6P2m3qc/sj40Eyjg MtAAq5GajgZZklDBW7L+W1VhLPxahoSG1Lwzoyw4Qp0w6G21FCLVtT36bBnr3tznud45rElJydy c4Y44nueQ7LAPP3I0Id9kX7rXuxYiplvSSXLrMpZzcvXYiydbqTyF3x5Kw7tUvxmtn619iadIVv Kire11PeS4+Y/9CLCA8y3cgxtX60Lkwdm8Crv1t6OnM8c6HUD258nsFxk9J/4vFLTjzykvQN+4p DjoYq7HV0K5b714nrz0F86BzJKxnhaiZ/S6a1a+CcPJlz3qy1wTzoee5hlZbQJ897OWmHVi7U5u gRaD2tk3ORCS8KGIe0l01xgHGKZlLV4ydurRPjq4WLD5PgOd0CNBaKc3dxFvTTn9og+a1D63ERz 35fNnTgiTde7RE01n1IP103VJG+2eAMU8+I4mzCUBNpPfkFAQskK8dk31C3DpYZnbp2u3akpwH2 PgO26yog1Tq6YuKhCQKybq8RsPpWejX0OSwH1AzS6Qlum7aQr1DjBlQ5pCtMBLjKhoSpilGHmEW LpSTaE7KKGHggWDn1gmEaAh1MA== X-Received: by 2002:a17:90b:2f4e:b0:39e:6c68:fd91 with SMTP id 98e67ed59e1d1-3b5cb8698d9mr1817537a91.38.1796336489010; Thu, 03 Dec 2026 14:21:29 -0800 (PST) Received: from cxlqual ([220.120.90.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc15bc2sm704932a91.3.2026.12.03.14.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 14:21:28 -0800 (PST) From: Anisa Su X-Google-Original-From: Anisa Su Date: Fri, 4 Dec 2026 07:23:21 +0900 To: Jonathan Cameron Cc: Anisa Su , linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, Dave Jiang , Alison Schofield , Davidlohr Bueso , Ira Weiny , Vishal Verma , Fan Ni , Li Ming , Benjamin Cheatham , Gregory Price , Richard Cheng Subject: Re: [PATCH v1 03/14] cxl/region: Add dynamic DAX region support Message-ID: References: <20261104230445.66625-1-anisa.su@samsung.com> <20261104230445.66625-4-anisa.su@samsung.com> <20261117023201.5eee045c@jic23-hlaptop> X-Mailing-List: linux-kernel@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=us-ascii Content-Disposition: inline In-Reply-To: <20261117023201.5eee045c@jic23-hlaptop> On Tue, Nov 17, 2026 at 02:32:01AM +0000, Jonathan Cameron wrote: > On Thu, 5 Nov 2026 08:02:27 +0900 > Anisa Su wrote: > > > From: Ira Weiny > > > > CXL DAX regions must allow memory to be added or removed dynamically > > to support DCD. In addition to the quantity of memory available, the > > location of the memory within a DC partition is dynamic, based on the > > extents offered by a device. CXL DAX regions must accommodate the > > dynamic movement of this memory in the management of DAX regions and > > devices. > > > > Introduce the concept of a dynamic DAX region. A dynamic region > > carries the shareable and read-only properties of the partitions it > > decodes, fixed when the region is created: every endpoint decoder > > attached to it must point at a partition with exactly those > > properties, and the region's 'mode' reports the matching selector. > > > > A dynamic region has no capacity when it is created, so the DAX device > > that cxl_dax_region_probe() creates for every region gets size 0 > > instead of the region size: a seed that claims no capacity the device > > has not offered yet. Its dax_region is created with IORESOURCE_DAX_DCD > no capacity has not been offered? no capacity as the device > has not offered any yet. perhaps. Yeah oops awkward wording. Combined with Alison's feedback: A dynamic region has no capacity when it is created, so the DAX device that cxl_dax_region_probe() creates for every region gets size 0 instead of the region size: a seed that claims no capacity, as the device has not offered any yet. Its dax_region reports 0 bytes available and is created with IORESOURCE_DAX_DCD rather than IORESOURCE_DAX_KMEM, so the DAX devices on it bind to device_dax and not to kmem. > > rather than IORESOURCE_DAX_KMEM, so the DAX devices on it bind to > > device_dax and not to kmem. > > > > Indicate 0 byte available capacity until such time that capacity is > > added. > > > > While DCD is disabled, auto region creation and the region 'target' > > write refuse endpoint decoders on a DC partition with -ENXIO, as the > > decoder 'mode' write already does. The sysfs entries for manual region > > creation follow in a separate patch. > > > > Additionally, dynamic regions complicate the range mapping of dax > > devices. There is no known use case for range mapping on dynamic > > regions. Avoid the complication by preventing range mapping of dax > > devices on dynamic regions. > > > > Interleaving is deferred for now. > > > > Based on an original patch by Navneet Singh. > > > > Signed-off-by: Ira Weiny > > Co-developed-by: Anisa Su > > Signed-off-by: Anisa Su > > Tested-by: Wonjae Lee > > Tested-by: Junhee Park > > Tested-by: Heesoo Kim > > A few small things inline. > > > @@ -2411,6 +2432,7 @@ static size_t store_targetN(struct cxl_region *cxlr, const char *buf, int pos, > > if (sysfs_streq(buf, "\n")) > > rc = detach_target(cxlr, pos); > > else { > > + struct cxl_endpoint_decoder *cxled; > > struct device *dev; > > > > dev = bus_find_device_by_name(&cxl_bus_type, NULL, buf); > > @@ -2422,8 +2444,14 @@ static size_t store_targetN(struct cxl_region *cxlr, const char *buf, int pos, > > goto out; > > } > > > > - rc = attach_target(cxlr, to_cxl_endpoint_decoder(dev), pos, > > - TASK_INTERRUPTIBLE); > > + cxled = to_cxl_endpoint_decoder(dev); > > + if (cxlr->mode == CXL_PARTMODE_DYNAMIC_RAM && > > + !cxled_dcd_enabled(cxled)) { > > + dev_dbg(dev, "DCD not enabled\n"); > > + rc = -ENXIO; > > + goto out; > > + } > > + rc = attach_target(cxlr, cxled, pos, TASK_INTERRUPTIBLE); > > out: > > put_device(dev); > Could tidy this up whilst here and use a __free() for the put device. > Entirely up to you though. > Good point, dropped the out: label > > } > > > @@ -3808,10 +3845,18 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, > > if (part < 0) > > return ERR_PTR(-EBUSY); > > There are quite a few cxled->part[part] lookups in this function. Perhaps > a local variable for that is worth introducing? > Added local variable const struct cxl_dpa_partition *dpa_part to use for the lookups. Thanks, Anisa > > > > + if (cxlds->part[part].mode == CXL_PARTMODE_DYNAMIC_RAM && > > + !cxled_dcd_enabled(cxled)) { > > + dev_dbg(&cxled->cxld.dev, "DCD not enabled\n"); > > + return ERR_PTR(-ENXIO); > > + } > > + > > do { > > cxlr = __create_region(cxlrd, cxlds->part[part].mode, > > atomic_read(&cxlrd->region_id), > > - cxled->cxld.target_type); > > + cxled->cxld.target_type, > > + cxlds->part[part].shareable, > > + cxlds->part[part].read_only); > > } while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY); > > > > if (IS_ERR(cxlr)) { > >