On Mon, 16 May 2022 at 21:51, Michael S. Tsirkin <m...@redhat.com> wrote: > > From: Jonathan Cameron <jonathan.came...@huawei.com> > > Both registers and the CFMWS entries in CDAT use simple encodings > for the number of interleave ways and the interleave granularity. > Introduce simple conversion functions to/from the unencoded > number / size. So far the iw decode has not been needed so is > it not implemented. > > Signed-off-by: Jonathan Cameron <jonathan.came...@huawei.com> > Reviewed-by: Alex Bennée <alex.ben...@linaro.org> > Message-Id: <20220429144110.25167-27-jonathan.came...@huawei.com> > Reviewed-by: Michael S. Tsirkin <m...@redhat.com> > Signed-off-by: Michael S. Tsirkin <m...@redhat.com> > --- > include/hw/cxl/cxl_component.h | 8 ++++++++ > hw/cxl/cxl-component-utils.c | 34 ++++++++++++++++++++++++++++++++++ > 2 files changed, 42 insertions(+) > > diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h > index 7d8f395cbe..4f69688c47 100644 > --- a/include/hw/cxl/cxl_component.h > +++ b/include/hw/cxl/cxl_component.h > @@ -210,4 +210,12 @@ static inline int cxl_decoder_count_enc(int count) > return 0; > } > > +uint8_t cxl_interleave_ways_enc(int iw, Error **errp); > +uint8_t cxl_interleave_granularity_enc(uint64_t gran, Error **errp); > + > +static inline hwaddr cxl_decode_ig(int ig) > +{ > + return 1 << (ig + 8); > +}
Hi; Coverity warns about this (CID 1488868) because the shift is calculated with 32-bit arithmetic but the function returns a 64-bit result. I assume that 'ig' is supposed to never be large enough that the result is >4GB, but we can make Coverity happy by using "1ULL" here. thanks -- PMM