]> git.itanic.dy.fi Git - linux-stable/commit
cxl/hdm: Use 4-byte reads to retrieve HDM decoder base+limit
authorDan Williams <dan.j.williams@intel.com>
Fri, 14 Apr 2023 18:54:00 +0000 (11:54 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 18 Apr 2023 17:32:46 +0000 (10:32 -0700)
commit1423885c84a5b3a53b79bcf241b18124d0d7cba6
tree4c7281d5a9b031dc75da3310b9a34e1d085d0410
parent7701c8bef4f14bd9f7940c6ed0e6a73584115a96
cxl/hdm: Use 4-byte reads to retrieve HDM decoder base+limit

The CXL specification mandates that 4-byte registers must be accessed
with 4-byte access cycles. CXL 3.0 8.2.3 "Component Register Layout and
Definition" states that the behavior is undefined if (2) 32-bit
registers are accessed as an 8-byte quantity. It turns out that at least
one hardware implementation is sensitive to this in practice. The @size
variable results in zero with:

    size = readq(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(which));

...and the correct size with:

    lo = readl(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(which));
    hi = readl(hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(which));
    size = (hi << 32) + lo;

Fixes: d17d0540a0db ("cxl/core/hdm: Add CXL standard decoder enumeration to the core")
Cc: <stable@vger.kernel.org>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://lore.kernel.org/r/168149844056.792294.8224490474529733736.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/hdm.c