Re: [RFC PATCH v2 3/5] PCI/TSM: Derive the coherent-range IPA from CXL

From: Ankit Agrawal

Date: Fri Nov 06 2026 - 07:16:47 EST


>> +
>> +                     reporting_bar_base = tsm_offset &
>> +                                          ~((u64)range_len(&window) - 1);
>
> Hi Ankit,
>
> HDM decoder window can have non-power-of-2 sizes, why do we assume a power-of-2 size for
> coherent window?

Hi Richard, yeah the region base calculation needs to be updated
to correctly determine the CXL region base for the
non-powerof2 sizes.

> E.g. if we have something like the following
> Window start: 4GB
> Window size: 768 MB
> Reported address: 4GB + 256 MB
>
> Assume MMIO_REPORTING_OFFSET is 0, so no address obfuscation needs to be removed.
> The reported page is simply 256 MB into the window.
>
> For this size, the mask leaves the reported address unchanged.
>
> 0x110000000 & ~(0x30000000 - 1) = 0x110000000
>
> reporting_bar_base becomes 4GB + 256 MB, rather than actual window base of 4 GB, so
> range_off is 0.
>
> The fianl address will be window.start + range_off = 4GB + 0
>
> A KUnit test against your patch series can reproduce this.
> Furthermore, pci_tsm_mmio_setup() accepts the wrong result, because the incorrect address
> is still insdie the window.
>
> Best regards,
> Richard Cheng.