[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL v2 28/86] hw/cxl/component: Add utils for interleave parameter
From: |
Peter Maydell |
Subject: |
Re: [PULL v2 28/86] hw/cxl/component: Add utils for interleave parameter encoding/decoding |
Date: |
Mon, 27 Jun 2022 14:29:19 +0100 |
On Mon, 16 May 2022 at 21:51, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> From: Jonathan Cameron <jonathan.cameron@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.Cameron@huawei.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Message-Id: <20220429144110.25167-27-Jonathan.Cameron@huawei.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@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
- Re: [PULL v2 28/86] hw/cxl/component: Add utils for interleave parameter encoding/decoding,
Peter Maydell <=