Re: [PATCH RFC 2/2] cxl/memdev: Remove temporary variables from cxl_memdev_state

Ira Weiny
2025-01-29T16:32:49Z

Alejandro Lucero Palau wrote:
>
> On 1/28/25 18:51, Ira Weiny wrote:
> > As was mentioned by Dan[1] cxl_memdev_state stores values which are only
> > used during device probe. This clutters the data structure and is a
> > hindrance on code maintenance. Those values are best handled with
> > temporary variables.
> >
> > Adjust the query of memory devices to read byte sizes in one call which
> > takes partition information into account. Use the values to create
> > partitions for device state initialization. Take care to separate the
> > mailbox queries from the initialization of device state to steer the
> > mbox code toward taking mailbox objects rather than memdev states.
> > Update spec references while changing these calls.
> >
> > Link: https://lore.kernel.org/all/67871f05cd767_20f32947f@dwillia2-xfh.jf.intel.com.notmuch/ [1]
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
>
>
> Reviewed-by: Alejandro Lucero <alucerop@amd.com>
>
>
> FWIW, I had (as part of current in-progress v10) similar struct than
> used here for Type2 initialization when there is no mailbox.
>
>
> I had added a specific function for initialising that struct, but my
> idea now with this change is to have cxl_mem_dev_info initialized by the
> driver before calling cxl_dev_state_identify,

Why is the accelerator calling cxl_dev_state_identify? I did not see that
in v9. My idea was that was a mailbox only call which is only needed for
memdevs. And cxl_add_partition() can be called by accelerators as a
convenience function to aid in creating cxl_dpa_info. (This and cxl_test
needed that function shared so it just got left in mbox.c)

> and inside that function

I'm not clear which 'that function' you are referring to here.

> checking if total_bytes already != 0 for avoiding call the mbox command
> for getting the info. This will support both cases for Type2, with and
> without mailbox.

I think I agree with you except the != 0 to avoid mailbox commands.

Unless I am miss-understanding Dan we need to get to a place where mailbox
commands stop filling in structures unless those work for both type 2 and
3 __and__ are optional. Because putting in special checks for the type
within a cxl/core/mailbox call is wrong IMO.

Ira