From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796336490; b=CcT6V7HFPtr2HLfB935AaHsD0p2zVP6c8fhG/FtEw8X6mWnL01QGCpOOVyL3Q1tgCgSq CQfPni/LYjNlYBJDfD3UYJ5qi9T/QeW7OM1m0d4cFIdJiMgMisAPFQ/bhaYBDfJDU9Dbp oRzoNLwXg7sLBO6lyV7qb95n7g/gQgXq5QsDP9Jlh3e17w9Teb9J+KL6tcx9veLFwTls5 Tu7tNyeVDpVQD5CfCyLGA5CRfGvqaQPpF2eWxWTQxMAAiiAUghcas9miQuEdaMukCCRWd E1avk598lZLyCXrV/pO9XqAAJAn5VLlphXBUfbRGh9g+WKLKPTLPheTVqG6l3aIZHwQ== 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=JGCf4AH50nJE+a6q6G7ZthglTS8Z6KxE4T/GnDd6tmZLwrS7uIZcTGkbDvmzE2zzDIGp sdF1I0I7zmxpGgh/ePqjS3zOPltHO8J6ziaMQ7ofX87D05z/ndoS6z7BmYhw+dAlHskJy /u8ZlX/cHxRzmQ55snsk59QhjSrWlRctOSnamda1YgrVfEpydUef5lzDyMbm1IVr9D07z hM0LgEGboj8Zs9kMV5F+50JtXCypXKZnX+j8Jp9gs/70hUjmCLT2QmSnyi3l1PHAsGRni EAON2VaPUEYX8q7mmhPdW34oy0/B0AEmH4c5ONSoulY2jB3cA12UEMeQJfABmyysh2w== 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.215.175 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 02C38606A32C for ; Thu, 3 Dec 2026 22:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02C38606A32C 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-pg1-f175.google.com with SMTP id 41be03b00d2f7-cdeaf4ea5e0so125412a12.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=X2+/p8HMpam+Zl3f5EfPgdacx9+LautgeF4FDFpY4dDZAu3yGceyzgVVvwak/VUiLG xIRwIRtdA0rO6qjv9+o/t5ebWh1py144TtijwzAsYUBFFR3CWDVP6YpMnz0djLIlSBo+ 4EM41fQqqhd6czAzBbhNsJRN1nXzRmxGAeMgH169wOSPW0BLkqsK1II/1vCKSSr039fq mdl3TuxkYWDHfrI5PtyRfyLapO32rs+2aAAkHHNGKaj9AX5VtJl8P8Wgtdm9eJDlzrlW AHQ8N6fHcNDyXV6HDgWxdlkViTZorHEjN84zFEbHdUK771DyyABFvsk6sNBg4rd07UyO 7bdw== X-Forwarded-Encrypted: i=1; AL+hErH6XDReAP+e8oyatDmXhEQYoo8RqGkUqeSQ6y+VNzHMH11KGzxZ3VAG6wONApGafJRIzaylNfYRY0Q=@vger.kernel.org X-Gm-Message-State: APuU4Z+5qSqZdhazTrMbxiToNiRLKm/grinSBAMmvqzKDpwpwrwWtSof zuxplRVU0tB9pVjWlArnAGkNm5IIE/XZEo2U6/Zqvf5retKgrd+vvFsN X-Gm-Gg: AZFdTZfr5equyfZwE4b7p0Ws9ykil/y9F5v/TJPhgd6ot2Hd1t3fW7sIO0NnEM89ELw uqzdDzm5s9lLck7N/nhMIwp9o0+8JTCt1HH2MXMWLjurzijlEsOr1Qegx3tQKDX9kytF/QToL9B A+bpcYBaiYmEzweBOHcVlzqzq16rGDNzUgECbLTTF3Z4HorwDLpIX7hxM2v0sb6xonNIGIKL5Wo kyy1/jp4WFCsS5plnvm9xbBtU44Va8EgkwllzF3SleYbkkXLPt/v5DiGo+yW274bC/HR762IkMq OQNsREIU3OnHdVktWoaQMMy9TghNsUNOc1NUhnNLqKWGPxwSHfk6pvkONQXhz9HKX+HJNLU//H8 /Ylx028hxd4JV8ItpFby6V6W9JHY/8csFPva+xGg2impQvBqpdBdCbYWtBxRLttMIi2uvEfnPMa 8ADTe+hmFGhoy/glJhPGcT+ysuz1cmm1AFGMN00WQoSlFzuarDHEKmUdQ1MgNOrGOWfFG11L8ik QPQqZEte69PpUJByAury0sW1HHAihkHZi1RsvlaiPpde1UOftF9BP61xJtJITMzfESro1jT5lZG /YIHgHblN1GRxQhFLWTBAc1M5g== 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-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=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)) { > >