lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67114ead9fc93_2cee29449@iweiny-mobl.notmuch>
Date: Thu, 17 Oct 2024 12:51:41 -0500
From: Ira Weiny <ira.weiny@...el.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>, <ira.weiny@...el.com>
CC: Dave Jiang <dave.jiang@...el.com>, Fan Ni <fan.ni@...sung.com>, "Navneet
 Singh" <navneet.singh@...el.com>, Jonathan Corbet <corbet@....net>, "Andrew
 Morton" <akpm@...ux-foundation.org>, Dan Williams <dan.j.williams@...el.com>,
	Davidlohr Bueso <dave@...olabs.net>, Alison Schofield
	<alison.schofield@...el.com>, Vishal Verma <vishal.l.verma@...el.com>,
	<linux-btrfs@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
	<linux-doc@...r.kernel.org>, <nvdimm@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 14/28] cxl/port: Add endpoint decoder DC mode support
 to sysfs

Jonathan Cameron wrote:
> On Mon, 07 Oct 2024 18:16:20 -0500
> ira.weiny@...el.com wrote:
> 
> > From: Navneet Singh <navneet.singh@...el.com>
> > 
> > Endpoint decoder mode is used to represent the partition the decoder
> > points to such as ram or pmem.
> > 
> > Expand the mode to allow a decoder to point to a specific DC partition
> > (Region).
> > 
> > Signed-off-by: Navneet Singh <navneet.singh@...el.com>
> > Co-developed-by: Ira Weiny <ira.weiny@...el.com>
> > Signed-off-by: Ira Weiny <ira.weiny@...el.com>
> 
> A few comments inline about ways that can make this a little tidier
> and less fragile.

All Done.  Yea good idea on the enum.

Ira


[snip]

> >  		(RW) When a CXL decoder is of devtype "cxl_decoder_endpoint" it
> >  		translates from a host physical address range, to a device local
> >  		address range. Device-local address ranges are further split
> > -		into a 'ram' (volatile memory) range and 'pmem' (persistent
> > -		memory) range. The 'mode' attribute emits one of 'ram', 'pmem',
> > -		'mixed', or 'none'. The 'mixed' indication is for error cases
> > -		when a decoder straddles the volatile/persistent partition
> > -		boundary, and 'none' indicates the decoder is not actively
> > -		decoding, or no DPA allocation policy has been set.
> > +		into a 'ram' (volatile memory) range, 'pmem' (persistent
> > +		memory) range, or Dynamic Capacity (DC) range.
> 		memory) range, and Dynamic Capacity (DC) ranges.
> 
> (doesn't work with preceding text otherwise)
> 

[snip]

> > +	if (mode >= CXL_DECODER_DC0 && mode <= CXL_DECODER_DC7) {
> > +		struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
> > +
> > +		rc = dc_mode_to_region_index(mode);
> > +		if (!resource_size(&cxlds->dc_res[rc])) {
> > +			dev_dbg(dev, "no available dynamic capacity\n");
> > +			rc = -ENXIO;
> > +			goto out;
> Probably worth adding a precursor patch that uses guard(rwsem_write) on
> the cxl_dpa_rwsem
> Allows for early returns simplifying existing code and this.

[snip]

> > diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> > index 85b912c11f04..23b4f266a83a 100644
> > --- a/drivers/cxl/core/port.c
> > +++ b/drivers/cxl/core/port.c
> > @@ -205,11 +205,11 @@ static ssize_t mode_store(struct device *dev, struct device_attribute *attr,
> >  	enum cxl_decoder_mode mode;
> >  	ssize_t rc;
> >  
> > -	if (sysfs_streq(buf, "pmem"))
> > -		mode = CXL_DECODER_PMEM;
> > -	else if (sysfs_streq(buf, "ram"))
> > -		mode = CXL_DECODER_RAM;
> > -	else
> > +	for (mode = CXL_DECODER_RAM; mode < CXL_DECODER_MIXED; mode++)
> > +		if (sysfs_streq(buf, cxl_decoder_mode_names[mode]))
> > +			break;
> > +
> Loop over them all then do what you have here but explicit matches
> to reject the ones that can't be set.
> Add a MODE_COUNT to the end of the options.
> 
> 	for (mode = 0; mode < CXL_DECODER_MODE_COUNT; mode++)
> 		if (sysfs_streq(buf, cxl_decoder_mode_names[mode]))
> 			break;
> 
> 	if (mode == CXL_DECODER_MODE_COUNT)
> 		return -EINVAL;
> 
> 	if (mode == CXL_DECODER_NONE)
> 		return -EINVAL;
> 
> 	/* Not yet supported */
> 	if (mode == CXL_DECODER_MIXED)
> 		return -EINVAL;
> ...
> 
> > +	if (mode >= CXL_DECODER_MIXED)
> >  		return -EINVAL;
> >  
> >  	rc = cxl_dpa_set_mode(cxled, mode);
> > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> > index 8b7099c38a40..cbaacbe0f36d 100644
> > --- a/drivers/cxl/cxl.h
> > +++ b/drivers/cxl/cxl.h
> > @@ -365,6 +365,9 @@ struct cxl_decoder {
> >  /*
> >   * CXL_DECODER_DEAD prevents endpoints from being reattached to regions
> >   * while cxld_unregister() is running
> > + *
> > + * NOTE: CXL_DECODER_RAM must be second and CXL_DECODER_MIXED must be last.
> This is a bit ugly. I'd change the logic a bit to avoid it.
> The list of things we don't support is short so just check for them.
> See above.
> 

[snip]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ