cxl/region: Prepare the decoder match range helper for reuse
authorAlison Schofield <alison.schofield@intel.com>
Thu, 26 Oct 2023 15:46:54 +0000 (08:46 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 26 Oct 2023 15:46:54 +0000 (08:46 -0700)
commit1110581412c7a223439bb3ecdcdd9f4432e08231
tree0bc5a8e7b12469f1f330e9d1f7f58b49c61c38d1
parent0718588c7aaa7a1510b4de972370535b61dddd0d
cxl/region: Prepare the decoder match range helper for reuse

match_decoder_by_range() and decoder_match_range() both determine
if an HPA range matches a decoder. The first does it for root
decoders and the second one operates on switch decoders.

Tidy these up with clear naming and make the switch helper more
like the root decoder helper in style and functionality. Make it
take the actual range, rather than an endpoint decoder from which
it extracts the range. Require an exact match on switch decoders,
because unlike a root decoder that maps an entire region, Linux
only supports 1:1 mapping of switch to endpoint decoders. Note that
root-decoders are a super-set of switch-decoders and the range they
cover is a super-set of a region, hence the use of range_contains() for
that case.

Aside from aesthetics and maintainability, this is in preparation
for reuse.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Jim Harris <jim.harris@samsung.com>
Link: https://lore.kernel.org/r/011b1f498e1758bb8df17c5951be00bd8d489e3b.1698263080.git.alison.schofield@intel.com
[djbw: fixup root decoder vs switch decoder range checks]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/region.c