Skip to content

Commit 9ff3eec

Browse files
committed
cxl/region: Move coherence tracking into cxl_region_attach()
Each time the contents of a given HPA are potentially changed in a cache incoherent manner the CXL core sets CXL_REGION_F_INCOHERENT to invalidate CPU caches before the region is used. Successful invocation of attach_target() indicates that DPA has been newly assigned to a given HPA in the dynamic region creation flow. However, attach_target() is also reused in the autodiscovery flow where the region was activated by platform firmware. In that case there is no need to invalidate caches because that region is already in active use and nothing about the autodiscovery flow modifies the HPA-to-DPA relationship. In the autodiscovery case cxl_region_attach() exits early after determining the endpoint decoder is already correctly attached to the region. Fixes: a32320b ("cxl/region: Add region autodiscovery") Reviewed-by: Fan Ni <fan.ni@samsung.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/168002858817.50647.1217607907088920888.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 030f880 commit 9ff3eec

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/cxl/core/region.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,7 @@ static int cxl_region_attach(struct cxl_region *cxlr,
16741674
if (rc)
16751675
goto err_decrement;
16761676
p->state = CXL_CONFIG_ACTIVE;
1677+
set_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
16771678
}
16781679

16791680
cxled->cxld.interleave_ways = p->interleave_ways;
@@ -1775,8 +1776,6 @@ static int attach_target(struct cxl_region *cxlr,
17751776

17761777
down_read(&cxl_dpa_rwsem);
17771778
rc = cxl_region_attach(cxlr, cxled, pos);
1778-
if (rc == 0)
1779-
set_bit(CXL_REGION_F_INCOHERENT, &cxlr->flags);
17801779
up_read(&cxl_dpa_rwsem);
17811780
up_write(&cxl_region_rwsem);
17821781
return rc;

0 commit comments

Comments
 (0)