Re: [PATCH v6] cxl/region: Fix wrong logic for finding a free switch cxl decoder

From: Dan Williams
Date: Wed Oct 16 2024 - 19:02:38 EST


Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>
> Provided that all child switch cxl decoders are sorted by ID in ascending
> order, then it is wrong for current match_free_decoder()'s logic to find
> a free cxl decoder as explained below:
>
> Port
> ├── cxld A <----> region A
> ├── cxld B // no region
> ├── cxld C <----> region C
>
> Current logic will find cxld B as a free one, but cxld B is not true
> free since region C has not been torn down, so current logic is wrong.
>
> Fixed by verifying if cxl decoder with ID (@port->commit_end + 1) can
> be returned as finding result.
>
> Link: https://lore.kernel.org/all/670af54931b8_964fe29427@xxxxxxxxxxxxxxxxxxxxxxxxx.notmuch/
> Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
> ---
> This patch is incremental to below patch series with title "cxl: Initialization and shutdown fixes"
> http://lore.kernel.org/172862483180.2150669.5564474284074502692.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> This patch is based on Dan's recommendation shown by below link:
> https://lore.kernel.org/all/670af54931b8_964fe29427@xxxxxxxxxxxxxxxxxxxxxxxxx.notmuch/

...and Dan and already sent a patch he is happier with here:

http://lore.kernel.org/172895072669.39002.9296583943188706348.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx