Re: [PATCH v4 1/2] cxl/region: Find free cxl decoder by device_for_each_child()

From: Zijun Hu
Date: Thu Oct 10 2024 - 09:48:46 EST


On 2024/9/11 02:27, Dan Williams wrote:
> Dan Williams wrote:
> [..]
>> So, while regionB would be the next decoder to allocate after regionC is
>> torn down, it is not a free decoder while decoderC and regionC have not been
>> reclaimed.
>
> The "simple" conversion is bug compatible with the current
> implementation, but here's a path to both constify the
> device_find_child() argument, *and* prevent unwanted allocations by
> allocating decoders precisely by id. Something like this, it passes a
> quick unit test run:
>

I submitted changes suggested by Dan as shown by below link:
https://patchwork.kernel.org/project/cxl/patch/20240917-const_dfc_prepare-v5-1-0e20f673ee0c@xxxxxxxxxxx/

I also made a little modification based on that Dan suggested.
welcome to code review again (^^).

Sorry for this noise (^^).

> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 1d5007e3795a..749a281819b4 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1750,7 +1750,8 @@ static int cxl_decoder_init(struct cxl_port *port, struct cxl_decoder *cxld)
> struct device *dev;
> int rc;
>
[snip]