Re: [PATCH v4 2/3] cxl/pci: Get rid of pointer arithmetic reading CDAT table

From: Robert Richter
Date: Sun Feb 25 2024 - 09:21:51 EST


On 19.02.24 12:50:59, Jonathan Cameron wrote:
> On Fri, 16 Feb 2024 16:58:43 +0100
> Robert Richter <rrichter@xxxxxxx> wrote:
>
> > Reading the CDAT table using DOE requires a Table Access Response
> > Header in addition to the CDAT entry. In current implementation this
> > has caused offsets with sizeof(__le32) to the actual buffers. This led
> > to hardly readable code and even bugs. E.g., see fix of devm_kfree()
> > in read_cdat_data():
> >
> > c65efe3685f5 cxl/cdat: Free correct buffer on checksum error
> >
> > Rework code to avoid calculations with sizeof(__le32). Introduce
> > struct cdat_doe_rsp for this which contains the Table Access Response
> > Header and a variable payload size for various data structures
> > afterwards to access the CDAT table and its CDAT Data Structures
> > without recalculating buffer offsets.
> >
> > Cc: Lukas Wunner <lukas@xxxxxxxxx>
> > Cc: Fan Ni <nifan.cxl@xxxxxxxxx>
> > Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> > Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> Ok. I suspect we could fine tune this for ever but changes here look good
> enough to me and definitely nicer than the original ;)
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

Thanks for your review of this series and also the v5 update for patch
#3.

-Robert