Skip to content

Commit a83383e

Browse files
committed
Merge branch 'cxl/for-6.13/dcd-prep' into cxl-for-next
Add preparation patches for coming soon DCD changes. - Add range_overlaps() - Add CDAT/DSMAS shared and read only flag in ACPICA - Add documentation to struct dev_dax_range - Delay event buffer allocation in CXL PCI - Use guard() in cxl_dpa_set_mode() - Refactor common create region code to reduce redudant code
2 parents 86bcd81 + a90326c commit a83383e

File tree

7 files changed

+56
-47
lines changed

7 files changed

+56
-47
lines changed

drivers/cxl/core/hdm.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
424424
struct cxl_memdev *cxlmd = cxled_to_memdev(cxled);
425425
struct cxl_dev_state *cxlds = cxlmd->cxlds;
426426
struct device *dev = &cxled->cxld.dev;
427-
int rc;
428427

429428
switch (mode) {
430429
case CXL_DECODER_RAM:
@@ -435,33 +434,25 @@ int cxl_dpa_set_mode(struct cxl_endpoint_decoder *cxled,
435434
return -EINVAL;
436435
}
437436

438-
down_write(&cxl_dpa_rwsem);
439-
if (cxled->cxld.flags & CXL_DECODER_F_ENABLE) {
440-
rc = -EBUSY;
441-
goto out;
442-
}
437+
guard(rwsem_write)(&cxl_dpa_rwsem);
438+
if (cxled->cxld.flags & CXL_DECODER_F_ENABLE)
439+
return -EBUSY;
443440

444441
/*
445442
* Only allow modes that are supported by the current partition
446443
* configuration
447444
*/
448445
if (mode == CXL_DECODER_PMEM && !resource_size(&cxlds->pmem_res)) {
449446
dev_dbg(dev, "no available pmem capacity\n");
450-
rc = -ENXIO;
451-
goto out;
447+
return -ENXIO;
452448
}
453449
if (mode == CXL_DECODER_RAM && !resource_size(&cxlds->ram_res)) {
454450
dev_dbg(dev, "no available ram capacity\n");
455-
rc = -ENXIO;
456-
goto out;
451+
return -ENXIO;
457452
}
458453

459454
cxled->mode = mode;
460-
rc = 0;
461-
out:
462-
up_write(&cxl_dpa_rwsem);
463-
464-
return rc;
455+
return 0;
465456
}
466457

467458
int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size)

drivers/cxl/core/region.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,9 +2536,8 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
25362536
return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTONLYMEM);
25372537
}
25382538

2539-
static ssize_t create_pmem_region_store(struct device *dev,
2540-
struct device_attribute *attr,
2541-
const char *buf, size_t len)
2539+
static ssize_t create_region_store(struct device *dev, const char *buf,
2540+
size_t len, enum cxl_decoder_mode mode)
25422541
{
25432542
struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(dev);
25442543
struct cxl_region *cxlr;
@@ -2548,31 +2547,26 @@ static ssize_t create_pmem_region_store(struct device *dev,
25482547
if (rc != 1)
25492548
return -EINVAL;
25502549

2551-
cxlr = __create_region(cxlrd, CXL_DECODER_PMEM, id);
2550+
cxlr = __create_region(cxlrd, mode, id);
25522551
if (IS_ERR(cxlr))
25532552
return PTR_ERR(cxlr);
25542553

25552554
return len;
25562555
}
2556+
2557+
static ssize_t create_pmem_region_store(struct device *dev,
2558+
struct device_attribute *attr,
2559+
const char *buf, size_t len)
2560+
{
2561+
return create_region_store(dev, buf, len, CXL_DECODER_PMEM);
2562+
}
25572563
DEVICE_ATTR_RW(create_pmem_region);
25582564

25592565
static ssize_t create_ram_region_store(struct device *dev,
25602566
struct device_attribute *attr,
25612567
const char *buf, size_t len)
25622568
{
2563-
struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(dev);
2564-
struct cxl_region *cxlr;
2565-
int rc, id;
2566-
2567-
rc = sscanf(buf, "region%d\n", &id);
2568-
if (rc != 1)
2569-
return -EINVAL;
2570-
2571-
cxlr = __create_region(cxlrd, CXL_DECODER_RAM, id);
2572-
if (IS_ERR(cxlr))
2573-
return PTR_ERR(cxlr);
2574-
2575-
return len;
2569+
return create_region_store(dev, buf, len, CXL_DECODER_RAM);
25762570
}
25772571
DEVICE_ATTR_RW(create_ram_region);
25782572

drivers/cxl/pci.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,6 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge,
777777
return 0;
778778
}
779779

780-
rc = cxl_mem_alloc_event_buf(mds);
781-
if (rc)
782-
return rc;
783-
784780
rc = cxl_event_get_int_policy(mds, &policy);
785781
if (rc)
786782
return rc;
@@ -794,6 +790,10 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge,
794790
return -EBUSY;
795791
}
796792

793+
rc = cxl_mem_alloc_event_buf(mds);
794+
if (rc)
795+
return rc;
796+
797797
rc = cxl_event_irqsetup(mds);
798798
if (rc)
799799
return rc;

drivers/dax/dax-private.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,30 @@ struct dax_region {
4040
struct device *youngest;
4141
};
4242

43+
/**
44+
* struct dax_mapping - device to display mapping range attributes
45+
* @dev: device representing this range
46+
* @range_id: index within dev_dax ranges array
47+
* @id: ida of this mapping
48+
*/
4349
struct dax_mapping {
4450
struct device dev;
4551
int range_id;
4652
int id;
4753
};
4854

55+
/**
56+
* struct dev_dax_range - tuple represenging a range of memory used by dev_dax
57+
* @pgoff: page offset
58+
* @range: resource-span
59+
* @mapping: reference to the dax_mapping for this range
60+
*/
61+
struct dev_dax_range {
62+
unsigned long pgoff;
63+
struct range range;
64+
struct dax_mapping *mapping;
65+
};
66+
4967
/**
5068
* struct dev_dax - instance data for a subdivision of a dax region, and
5169
* data while the device is activated in the driver.
@@ -58,7 +76,7 @@ struct dax_mapping {
5876
* @dev - device core
5977
* @pgmap - pgmap for memmap setup / lifetime (driver owned)
6078
* @nr_range: size of @ranges
61-
* @ranges: resource-span + pgoff tuples for the instance
79+
* @ranges: range tuples of memory used
6280
*/
6381
struct dev_dax {
6482
struct dax_region *region;
@@ -72,11 +90,7 @@ struct dev_dax {
7290
struct dev_pagemap *pgmap;
7391
bool memmap_on_memory;
7492
int nr_range;
75-
struct dev_dax_range {
76-
unsigned long pgoff;
77-
struct range range;
78-
struct dax_mapping *mapping;
79-
} *ranges;
93+
struct dev_dax_range *ranges;
8094
};
8195

8296
/*

fs/btrfs/ordered-data.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 file_offset,
111111
return NULL;
112112
}
113113

114-
static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
115-
u64 len)
114+
static int btrfs_range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
115+
u64 len)
116116
{
117117
if (file_offset + len <= entry->file_offset ||
118118
entry->file_offset + entry->num_bytes <= file_offset)
@@ -985,7 +985,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
985985

986986
while (1) {
987987
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
988-
if (range_overlaps(entry, file_offset, len))
988+
if (btrfs_range_overlaps(entry, file_offset, len))
989989
break;
990990

991991
if (entry->file_offset >= file_offset + len) {
@@ -1114,12 +1114,12 @@ struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range(
11141114
}
11151115
if (prev) {
11161116
entry = rb_entry(prev, struct btrfs_ordered_extent, rb_node);
1117-
if (range_overlaps(entry, file_offset, len))
1117+
if (btrfs_range_overlaps(entry, file_offset, len))
11181118
goto out;
11191119
}
11201120
if (next) {
11211121
entry = rb_entry(next, struct btrfs_ordered_extent, rb_node);
1122-
if (range_overlaps(entry, file_offset, len))
1122+
if (btrfs_range_overlaps(entry, file_offset, len))
11231123
goto out;
11241124
}
11251125
/* No ordered extent in the range */

include/acpi/actbl1.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ struct acpi_cdat_dsmas {
403403
/* Flags for subtable above */
404404

405405
#define ACPI_CDAT_DSMAS_NON_VOLATILE (1 << 2)
406+
#define ACPI_CDAT_DSMAS_SHAREABLE (1 << 3)
407+
#define ACPI_CDAT_DSMAS_READ_ONLY (1 << 6)
406408

407409
/* Subtable 1: Device scoped Latency and Bandwidth Information Structure (DSLBIS) */
408410

include/linux/range.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ static inline u64 range_len(const struct range *range)
1313
return range->end - range->start + 1;
1414
}
1515

16+
/* True if r1 completely contains r2 */
1617
static inline bool range_contains(const struct range *r1,
1718
const struct range *r2)
1819
{
1920
return r1->start <= r2->start && r1->end >= r2->end;
2021
}
2122

23+
/* True if any part of r1 overlaps r2 */
24+
static inline bool range_overlaps(const struct range *r1,
25+
const struct range *r2)
26+
{
27+
return r1->start <= r2->end && r1->end >= r2->start;
28+
}
29+
2230
int add_range(struct range *range, int az, int nr_range,
2331
u64 start, u64 end);
2432

0 commit comments

Comments
 (0)