mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Anisa Su <anisa.su887@gmail.com>
Cc: Richard Cheng <icheng@nvidia.com>,
	linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Dan Williams <djbw@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Ira Weiny <iweiny@kernel.org>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Fan Ni <nifan.cxl@gmail.com>, Li Ming <ming.li@zohomail.com>,
	Benjamin Cheatham <benjamin.cheatham@amd.com>,
	Gregory Price <gourry@gourry.net>
Subject: Re: [PATCH v15 2/8] cxl/mem: Read dynamic capacity configuration from the device
Date: Mon, 12 Oct 2026 12:26:03 +0100	[thread overview]
Message-ID: <20261012122603.06c71c62@jic23-hlaptop> (raw)
In-Reply-To: <asrBsS556W6ijUMH@cxlqual>


Please remember to crop down to only the context you need!
(grumpy as on a train and the pagedown key on my laptop requires pressing far too
many things at once!)

> > > diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> > > index b3419df586b9..def26c490dfe 100644
> > > --- a/drivers/cxl/core/memdev.c
> > > +++ b/drivers/cxl/core/memdev.c
> > > @@ -643,6 +643,53 @@ int cxl_mem_dpa_fetch(struct cxl_memdev_state *mds, struct cxl_dpa_info *info)
> > >  }
> > >  EXPORT_SYMBOL_NS_GPL(cxl_mem_dpa_fetch, "CXL");
> > >  
> > > +int cxl_configure_dcd(struct cxl_memdev_state *mds, struct cxl_dpa_info *info)
> > > +{
> > > +	struct cxl_dc_partition_info dc_info = { };
> > > +	struct device *dev = mds->cxlds.dev;
> > > +	u64 total;
> > > +	int rc;
> > > +
> > > +	if (!mds->cxlds.media_ready)
> > > +		return 0;
> > > +
> > > +	rc = cxl_dev_dc_identify(&mds->cxlds.cxl_mbox, &dc_info);
> > > +	if (rc) {
> > > +		dev_warn(dev,
> > > +			 "Failed to read Dynamic Capacity config: %d\n", rc);
> > > +		return rc;
> > > +	}
> > > +
> > > +	if (dc_info.start < info->size) {
> > > +		dev_err(dev,
> > > +			"DC partition 0 base %#llx overlaps static capacity ending at %#llx\n",
> > > +			dc_info.start, info->size);
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	/* A gap between static capacity and the DC partition is not supported */
> > > +	if (dc_info.start > info->size) {
> > > +		dev_warn(dev,
> > > +			 "DC partition 0 base %#llx leaves a gap from static capacity ending at %#llx\n",
> > > +			 dc_info.start, info->size);
> > > +		return -EOPNOTSUPP;
> > > +	}
> > > +
> > > +	if (check_add_overflow(info->size, dc_info.size, &total)) {
> > > +		dev_err(dev,
> > > +			"DC partition 0 size %#llx overflows DPA space ending at %#llx\n",
> > > +			dc_info.size, info->size);
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	info->size = total;
> > > +	dev_dbg(dev, "Adding dynamic ram partition; %#llx size %#llx\n",
> > > +		dc_info.start, dc_info.size);
> > > +	add_part(info, dc_info.start, dc_info.size, CXL_PARTMODE_DYNAMIC_RAM);
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL_NS_GPL(cxl_configure_dcd, "CXL");
> > >   
> > 
> > Hi Anisa,
> > 
> > This function uses info->size, which is Total Capacity, as the end of static
> > capacity, but now we require DC partition to start at the end of the last
> > static partition, which is RAM + PMEM. CXL r4.0 8.2.10.9.1.1 "Identify Memory
> > Device" only requires Total Capacity to be >= the sum of RAM + PMEM.
> > If they differ and device place DCD region base at Total, we can pass the check
> > here but cxl_dpa_setup() fails probe with -EINVAL, so a DCD config
> > quirk costs the whole memdev instead of just DCD.
> > 
> > Think of an example, Total capacity 12G, RAM has 8G, PMEM has 2G, now if
> > DC starts at 12G, this function check will be passed, but cxl_dpa_setup()
> > will see PMEM end at 10G, DC start at 12G, think of it as a hole.
> > If the DC start at 10G, we can pass cxl_dpa_setup(), but the test here will see
> > 10G < 12 G and think DC region start inside the device memory and print
> > "overlaps"
> > 
> > Maybe derive the static end from info->part[nr_partitions - 1] and size
> > info->size from DC partition end ?
> >   
> Oh you're right.... fixed.

For this sort of thing where you are fully agreeing. 
Just fix it and acknowledge in change log!  That way there is no email
for others to get grumpy scrolling through :)

Jonathan

  reply	other threads:[~2026-10-12 11:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 20:16 [PATCH v15 0/8] DCD Prep Series Anisa Su
2026-10-07 20:16 ` [PATCH v15 1/8] cxl/mbox: Flag support for Dynamic Capacity Devices (DCD) Anisa Su
2026-10-07 20:16 ` [PATCH v15 2/8] cxl/mem: Read dynamic capacity configuration from the device Anisa Su
2026-10-07 23:43   ` Alison Schofield
2026-10-08  8:15     ` Anisa Su
2026-10-08  8:33   ` Richard Cheng
2026-10-10 22:52     ` Anisa Su
2026-10-12 11:26       ` Jonathan Cameron [this message]
2026-10-07 20:16 ` [PATCH v15 3/8] cxl/cdat: Gather DSMAS data for DCD partitions Anisa Su
2026-10-07 23:45   ` Alison Schofield
2026-10-08 21:29   ` Dave Jiang
2026-10-10 22:29     ` Anisa Su
2026-10-07 20:16 ` [PATCH v15 4/8] cxl/events: Split event msgnum configuration from irq setup Anisa Su
2026-10-07 20:16 ` [PATCH v15 5/8] cxl/pci: Factor out interrupt policy check Anisa Su
2026-10-07 20:16 ` [PATCH v15 6/8] cxl/mem: Configure dynamic capacity interrupts Anisa Su
2026-10-07 23:46   ` Alison Schofield
2026-10-08  8:58   ` Richard Cheng
2026-10-10 22:51     ` Anisa Su
2026-10-07 20:16 ` [PATCH v15 7/8] cxl/core: Enforce partition order/simplify partition calls Anisa Su
2026-10-07 20:16 ` [PATCH v15 8/8] Documentation/cxl: Document DPA partition layout and ordering rules Anisa Su
2026-10-08  8:26 ` [PATCH v15 0/8] DCD Prep Series Anisa Su

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=20261012122603.06c71c62@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=alison.schofield@intel.com \
    --cc=anisa.su887@gmail.com \
    --cc=benjamin.cheatham@amd.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=gourry@gourry.net \
    --cc=icheng@nvidia.com \
    --cc=iweiny@kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=nifan.cxl@gmail.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.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

all inboxes | Powered by JetHome®