Re: [PATCH v4 00/28] DCD: Add support for Dynamic Capacity Devices (DCD)

2024-10-21 Thread Fan Ni
| 131 +++- > drivers/cxl/pci.c | 123 +++- > drivers/dax/bus.c | 352 +++++-- > drivers/dax/bus.h | 4 +- > drivers/dax/cxl.c | 72 ++- > drivers/dax/dax-private.h | 47 +- > drivers/dax/hmem/hmem.c | 2 +- > drivers/dax/pmem.c| 2 +- > fs/btrfs/ordered-data.c | 10 +- > include/acpi/actbl1.h | 2 + > include/cxl/event.h | 32 + > include/linux/range.h | 7 + > lib/test_printf.c | 70 +++ > lib/vsprintf.c| 55 +- > tools/testing/cxl/Kbuild | 3 +- > tools/testing/cxl/test/mem.c | 960 > ++ > 29 files changed, 3576 insertions(+), 320 deletions(-) > --- > base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc > change-id: 20230604-dcd-type2-upstream-0cd15f6216fd > > Best regards, > -- > Ira Weiny > -- Fan Ni

Re: [PATCH v4 23/28] dax/bus: Factor out dev dax resize logic

2024-10-14 Thread Fan Ni
f %pa misaligned\n", &to_alloc)) > + return -ENXIO; > + > +retry: > + alloc = dev_dax_resize_static(&dax_region->res, dev_dax, to_alloc); > + if (alloc <= 0) > + return alloc; > to_alloc -= alloc; > if (to_alloc) > goto retry; > @@ -1198,7 +1225,8 @@ static ssize_t mapping_store(struct device *dev, struct > device_attribute *attr, > > to_alloc = range_len(&r); > if (alloc_is_aligned(dev_dax, to_alloc)) > - rc = alloc_dev_dax_range(dev_dax, r.start, to_alloc); > + rc = alloc_dev_dax_range(&dax_region->res, dev_dax, r.start, > + to_alloc); > up_write(&dax_dev_rwsem); > up_write(&dax_region_rwsem); > > @@ -1466,7 +1494,8 @@ static struct dev_dax *__devm_create_dev_dax(struct > dev_dax_data *data) > device_initialize(dev); > dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); > > - rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, data->size); > + rc = alloc_dev_dax_range(&dax_region->res, dev_dax, > dax_region->res.start, > + data->size); > if (rc) > goto err_range; > > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 22/28] cxl/region/extent: Expose region extent information in sysfs

2024-10-14 Thread Fan Ni
avneet Singh > Co-developed-by: Ira Weiny > Signed-off-by: Ira Weiny > Reviewed-by: Fan Ni Tested-by: Fan Ni > --- > Changes: > [djiang: Split sysfs docs up] > [iweiny: Adjust sysfs docs dates] > --- > Documentation/ABI/testing/sysfs-bus-cxl |

Re: [PATCH v4 21/28] cxl/extent: Process DCD events and realize region extents

2024-10-11 Thread Fan Ni
' is N times bigger than 'max_extents'(e,g. > > > cnt=20, max_extents=10). all responses will be sent in this > > > xa_for_each(), and CXL_DCD_EVENT_MORE will be set in the last response > > > but it should not be set in these cases. > > > > > > > Ah yes. cnt must be decremented. As I looked at the patch just now the > > > > if (cnt == 0 || pl_index) > > > > ... seemed very wrong to me. That change masked this bug. > > > > This should fix it: > > > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c > > index d66beec687a0..99200274dea8 100644 > > --- a/drivers/cxl/core/mbox.c > > +++ b/drivers/cxl/core/mbox.c > > @@ -1119,10 +1119,11 @@ static int cxl_send_dc_response(struct > > cxl_memdev_state *mds, int opcode, > > if (rc) > > return rc; > > pl_index = 0; > > + cnt -= pl_index; > > } > > } > > > > - if (cnt == 0 || pl_index) { > > I thought this cnt == 0 check was to deal with the no valid > extents case where an empty reply is needed. Agreed. Based on current code logic, there are two cases that cnt == 0: 1. no extent is accepted so cnt is passed as 0; 2. cnt was decreased to 0 and response has already been sent. For case 1, we still need to send a response with zero extents; For case 2, we do not need to handle. Fan > > > > + if (pl_index) { > > mbox_cmd = (struct cxl_mbox_cmd) { > > .opcode = opcode, > > .size_in = struct_size(response, extent_list, > > > > > > Thank you, and sorry again for missing your feedback. > > > > Ira > > > > [snip] > > > -- Fan Ni

Re: [PATCH v4 20/28] cxl/core: Return endpoint decoder information from region search

2024-10-10 Thread Fan Ni
HPA offset. In addition, well behaved > extents should be contained within an endpoint decoder. > > Return the endpoint decoder found to be used in subsequent DCD code. > > Signed-off-by: Ira Weiny Reviewed-by: Fan Ni > --- > drivers/cxl/core/core.h | 6 -- > driv

Re: [PATCH v4 19/28] cxl/mem: Configure dynamic capacity interrupts

2024-10-10 Thread Fan Ni
ms(mds, &policy, native_cxl); > if (rc) > return rc; > > @@ -790,12 +834,16 @@ static int cxl_event_config(struct pci_host_bridge > *host_bridge, > if (rc) > return rc; > > - rc = cxl_event_irqsetup(mds, &policy); > + rc = cxl_irqsetup(mds, &policy, native_cxl); > if (rc) > return rc; > > cxl_mem_get_event_records(mds, CXLDEV_EVENT_STATUS_ALL); > > + dev_dbg(mds->cxlds.dev, "Event config : %s DCD %s\n", > + native_cxl ? "OS" : "BIOS", > + cxl_dcd_supported(mds) ? "supported" : "not supported"); > + > return 0; > } > > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 18/28] cxl/pci: Factor out interrupt policy check

2024-10-10 Thread Fan Ni
nt interrupt configuration. > > Factor out event interrupt setting validation. > > Reviewed-by: Dave Jiang > Reviewed-by: Jonathan Cameron > Signed-off-by: Ira Weiny > Reviewed-by: Fan Ni > --- > Changes: > [iweiny: reword commit message] > [iweiny: keep revi

Re: [PATCH v4 17/28] cxl/events: Split event msgnum configuration from irq setup

2024-10-10 Thread Fan Ni
nt interrupt configuration. > > Split cxl_event_config_msgnums() from irq setup in preparation for > separate DCD interrupts configuration. > > Signed-off-by: Ira Weiny > --- One minor comment inline; otherwise Reviewed-by: Fan Ni > drivers/cxl/pci.c | 24 -

Re: [PATCH v4 16/28] cxl/region: Add sparse DAX region support

2024-10-10 Thread Fan Ni
ruct device *dev) > struct cxl_region *cxlr = cxlr_dax->cxlr; > struct dax_region *dax_region; > struct dev_dax_data data; > + resource_size_t dev_size; > + unsigned long flags; > > if (nid == NUMA_NO_NODE) > nid = memory_add_physaddr_to_nid(cxlr_dax->hpa_range.start); > > + flags = IORESOURCE_DAX_KMEM; > + if (cxlr->mode == CXL_REGION_DC) > + flags |= IORESOURCE_DAX_SPARSE_CAP; > + > dax_region = alloc_dax_region(dev, cxlr->id, &cxlr_dax->hpa_range, nid, > - PMD_SIZE, IORESOURCE_DAX_KMEM); > + PMD_SIZE, flags); > if (!dax_region) > return -ENOMEM; > > + if (cxlr->mode == CXL_REGION_DC) > + /* Add empty seed dax device */ > + dev_size = 0; > + else > + dev_size = range_len(&cxlr_dax->hpa_range); > + > data = (struct dev_dax_data) { > .dax_region = dax_region, > .id = -1, > - .size = range_len(&cxlr_dax->hpa_range), > + .size = dev_size, > .memmap_on_memory = true, > }; > > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 15/28] cxl/region: Refactor common create region code

2024-10-10 Thread Fan Ni
> Refactor create_pmem_region_store() and create_ram_region_store() to use > a single common function to be used in subsequent DC code. > > Suggested-by: Fan Ni > Signed-off-by: Ira Weiny > --- Reviewed-by: Fan Ni > drivers/cxl/core/region.c | 28 +++- > 1 file cha

Re: [PATCH v4 13/28] cxl/mem: Expose DCD partition capabilities in sysfs

2024-10-09 Thread Fan Ni
> \ > + .attrs = cxl_memdev_dc##n##_attributes, > \ > + .is_visible = SYSFS_GROUP_VISIBLE(cxl_memdev_dc##n), > \ > +} > +CXL_MEMDEV_DC_ATTR_GROUP(0); > +CXL_MEMDEV_DC_ATTR_GROUP(1); > +CXL_MEMDEV_DC_ATTR_GROUP(2); > +CXL_MEMDEV_DC_ATTR_GROUP(3); > +CXL_MEMDEV_DC_ATTR_GROUP(4); > +CXL_MEMDEV_DC_ATTR_GROUP(5); > +CXL_MEMDEV_DC_ATTR_GROUP(6); > +CXL_MEMDEV_DC_ATTR_GROUP(7); > + > static umode_t cxl_memdev_visible(struct kobject *kobj, struct attribute *a, > int n) > { > @@ -525,6 +643,14 @@ static struct attribute_group > cxl_memdev_security_attribute_group = { > }; > > static const struct attribute_group *cxl_memdev_attribute_groups[] = { > + &cxl_memdev_dc0_group, > + &cxl_memdev_dc1_group, > + &cxl_memdev_dc2_group, > + &cxl_memdev_dc3_group, > + &cxl_memdev_dc4_group, > + &cxl_memdev_dc5_group, > + &cxl_memdev_dc6_group, > + &cxl_memdev_dc7_group, > &cxl_memdev_attribute_group, > &cxl_memdev_ram_attribute_group, > &cxl_memdev_pmem_attribute_group, > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 12/28] cxl/cdat: Gather DSMAS data for DCD regions

2024-10-09 Thread Fan Ni
XL_MAX_DC_REGION]; > > struct cxl_event_state event; > struct cxl_poison_state poison; > diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h > index 199afc2cd122..387fc821703a 100644 > --- a/include/acpi/actbl1.h > +++ b/include/acpi/actbl1.h > @@ -403,6 +403,8 @@ struct acpi_cdat_dsmas { > /* Flags for subtable above */ > > #define ACPI_CDAT_DSMAS_NON_VOLATILE(1 << 2) > +#define ACPI_CDAT_DSMAS_SHAREABLE (1 << 3) > +#define ACPI_CDAT_DSMAS_READ_ONLY (1 << 6) > > /* Subtable 1: Device scoped Latency and Bandwidth Information Structure > (DSLBIS) */ > > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 09/28] cxl/core: Separate region mode from decoder mode

2024-10-09 Thread Fan Ni
oped-by: Ira Weiny > Signed-off-by: Ira Weiny > Reviewed-by: Fan Ni > --- > Changes: > [iweiny: rebase] > [Jonathan: remove dead code] > [Jonathan: clarify commit message] > --- > drivers/cxl/core/cdat.c | 6 ++-- > drivers/cxl/core/region.c

Re: [PATCH v4 06/28] cxl/pci: Delay event buffer allocation

2024-10-09 Thread Fan Ni
event configuration. > > Reviewed-by: Davidlohr Bueso > Reviewed-by: Dave Jiang > Reviewed-by: Jonathan Cameron > Signed-off-by: Ira Weiny > Reviewed-by: Fan Ni > --- > Changes: > [iweiny: keep tags for early simple patch] > [Davidlohr, Jonathan, djiang: move to be

Re: [PATCH v4 03/28] cxl/cdat: Use %pra for dpa range outputs

2024-10-09 Thread Fan Ni
y > To: Jonathan Corbet (maintainer:DOCUMENTATION) > Cc: linux-...@vger.kernel.org > Cc: linux-ker...@vger.kernel.org (open list) > Signed-off-by: Ira Weiny > --- Reviewed-by: Fan Ni > drivers/cxl/core/cdat.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-

Re: [PATCH v4 02/28] printk: Add print format (%pra) for struct range

2024-10-09 Thread Fan Ni
p, the number of bits is determined by the field > * width which must be explicitly specified either as part of the > * format string '%32b[l]' or through '%*b[l]', [l] selects > @@ -2399,8 +2437,13 @@ char *pointer(const char *fmt, char *buf, char *end, > void *ptr, > fallthrough; > case 'B': > return symbol_string(buf, end, ptr, spec, fmt); > - case 'R': > case 'r': > + switch (fmt[1]) { > + case 'a': > + return range_string(buf, end, ptr, spec, fmt); > + } > + fallthrough; > + case 'R': > return resource_string(buf, end, ptr, spec, fmt); > case 'h': > return hex_string(buf, end, ptr, spec, fmt); > > -- > 2.46.0 > -- Fan Ni

Re: [PATCH v4 01/28] test printk: Add very basic struct resource tests

2024-10-09 Thread Fan Ni
Petr Mladek > To: Steven Rostedt > To: Andy Shevchenko > To: Rasmus Villemoes > To: Sergey Senozhatsky > Cc: linux-...@vger.kernel.org > Signed-off-by: Ira Weiny Reviewed-by: Fan Ni Tested-by: Fan Ni > > --- > [lkp: ensure phys_addr_t is within limits fo

Re: [PATCH v4 00/28] DCD: Add support for Dynamic Capacity Devices (DCD)

2024-10-08 Thread Fan Ni
On Tue, Oct 08, 2024 at 03:57:13PM -0700, Fan Ni wrote: > On Mon, Oct 07, 2024 at 06:16:06PM -0500, Ira Weiny wrote: > > A git tree of this series can be found here: > > > > https://github.com/weiny2/linux-kernel/tree/dcd-v4-2024-10-04 > > > > Series info

Re: [PATCH v4 00/28] DCD: Add support for Dynamic Capacity Devices (DCD)

2024-10-08 Thread Fan Ni
-- > drivers/dax/bus.h | 4 +- > drivers/dax/cxl.c | 72 ++- > drivers/dax/dax-private.h | 47 +- > drivers/dax/hmem/hmem.c | 2 +- > drivers/dax/pmem.c| 2 +- > fs/btrfs/ordered-data.c | 10 +- > include/acpi/actbl1.h | 2 + > include/cxl/event.h | 32 + > include/linux/range.h | 7 + > lib/test_printf.c | 70 +++ > lib/vsprintf.c| 55 +- > tools/testing/cxl/Kbuild | 3 +- > tools/testing/cxl/test/mem.c | 960 > ++ > 29 files changed, 3576 insertions(+), 320 deletions(-) > --- > base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc > change-id: 20230604-dcd-type2-upstream-0cd15f6216fd > > Best regards, > -- > Ira Weiny > -- Fan Ni

Re: [PATCH v3 04/25] cxl/pci: Delay event buffer allocation

2024-09-05 Thread Fan Ni
event configuration. > > Reviewed-by: Davidlohr Bueso > Reviewed-by: Dave Jiang > Reviewed-by: Jonathan Cameron > Signed-off-by: Ira Weiny > > --- Reviewed-by: Fan Ni > Changes: > [iweiny: keep tags for early simple patch] > [Davidlohr, Jonathan, djiang: move to be

Re: [PATCH v3 23/25] cxl/mem: Trace Dynamic capacity Event Record

2024-09-05 Thread Fan Ni
g. > > Signed-off-by: Navneet Singh > Signed-off-by: Ira Weiny > With the following cxl spec version fixed, Reviewed-by: Fan Ni > --- > Changes: > [Alison: Update commit message] > --- > drivers/cxl/core/mbox

Re: [PATCH v3 22/25] cxl/region: Read existing extents on region creation

2024-09-05 Thread Fan Ni
y > Signed-off-by: Ira Weiny With the minor things fixed mentioned by Jonathan and Dave, Reviewed-by: Fan Ni > > --- > Changes: > [iweiny: Leverage the new add path from the event processing code such >that the adding and surfacing of extents flows through the same &

Re: [PATCH v3 18/25] cxl/extent: Process DCD events and realize region extents

2024-09-05 Thread Fan Ni
On Fri, Aug 16, 2024 at 09:44:26AM -0500, ira.we...@intel.com wrote: > From: Navneet Singh > > A dynamic capacity device (DCD) sends events to signal the host for > changes in the availability of Dynamic Capacity (DC) memory. These > events contain extents describing a DPA range and meta data fo

Re: [PATCH v3 19/25] cxl/region/extent: Expose region extent information in sysfs

2024-08-28 Thread Fan Ni
avneet Singh > Co-developed-by: Ira Weiny > Signed-off-by: Ira Weiny Reviewed-by: Fan Ni > > --- > Changes: > [iweiny: split this out] > [Jonathan: add documentation for extent sysfs] > [Jonathan/djbw: s/label/tag] > [Jonathan/djbw: treat tag as uuid] > [djbw: use

Re: [PATCH v3 18/25] cxl/extent: Process DCD events and realize region extents

2024-08-27 Thread Fan Ni
On Tue, Aug 27, 2024 at 01:08:29PM +0100, Jonathan Cameron wrote: > On Fri, 23 Aug 2024 14:32:32 -0700 > Fan Ni wrote: > > > On Fri, Aug 16, 2024 at 09:44:26AM -0500, ira.we...@intel.com wrote: > > > From: Navneet Singh > > > > > > A dynamic capaci

Re: [PATCH v3 18/25] cxl/extent: Process DCD events and realize region extents

2024-08-23 Thread Fan Ni
On Fri, Aug 16, 2024 at 09:44:26AM -0500, ira.we...@intel.com wrote: > From: Navneet Singh > > A dynamic capacity device (DCD) sends events to signal the host for > changes in the availability of Dynamic Capacity (DC) memory. These > events contain extents describing a DPA range and meta data fo

Re: [PATCH v3 15/25] cxl/pci: Factor out interrupt policy check

2024-08-22 Thread Fan Ni
nt interrupt configuration. > > Factor out event interrupt setting validation. > > Reviewed-by: Dave Jiang > Reviewed-by: Jonathan Cameron > Signed-off-by: Ira Weiny > Reviewed-by: Fan Ni > --- > Changes: > [iweiny: reword commit message] > [iweiny: keep revi

Re: [PATCH v3 14/25] cxl/events: Split event msgnum configuration from irq setup

2024-08-22 Thread Fan Ni
nt interrupt configuration. > > Split cxl_event_config_msgnums() from irq setup in preparation for > separate DCD interrupts configuration. > > Signed-off-by: Ira Weiny > --- Reviewed-by: Fan Ni > drivers/cxl/pci.c | 24 > 1 file changed, 12 inse

Re: [PATCH v3 12/25] cxl/region: Refactor common create region code

2024-08-22 Thread Fan Ni
> Refactor create_pmem_region_store() and create_ram_region_store() to use > a single common function to be used in subsequent DC code. > > Suggested-by: Fan Ni > Signed-off-by: Ira Weiny > --- Reviewed-by: Fan Ni > drivers/cxl/core/region.c | 28 +++- > 1 file cha

Re: [PATCH v3 13/25] cxl/region: Add sparse DAX region support

2024-08-22 Thread Fan Ni
On Fri, Aug 16, 2024 at 09:44:21AM -0500, ira.we...@intel.com wrote: > From: Navneet Singh > > Dynamic Capacity CXL regions must allow memory to be added or removed > dynamically. In addition to the quantity of memory available the > location of the memory within a DC partition is dynamic based

Re: [PATCH v3 06/25] cxl/mem: Read dynamic capacity configuration from the device

2024-08-20 Thread Fan Ni
On Fri, Aug 16, 2024 at 02:45:47PM -0700, Dave Jiang wrote: > > > On 8/16/24 7:44 AM, ira.we...@intel.com wrote: > > From: Navneet Singh > > > > Devices which optionally support Dynamic Capacity (DC) are configured > > via mailbox commands. CXL 3.1 requires the host to issue the Get DC > > Con