[Intel-gfx] [PATCH v4] drm/i915/dsb: DSB code refactoring
Luca Coelho
luca at coelho.fi
Tue Oct 31 07:44:18 UTC 2023
On Fri, 2023-10-27 at 17:27 +0530, Animesh Manna wrote:
> Refactor DSB implementation to be compatible with Xe driver.
>
> v1: RFC version.
> v2: Make intel_dsb structure opaque from external usage. [Jani]
> v3: Rebased on latest.
> v4:
> - Add boundary check in dsb_buffer_memset(). [Luca]
> - Use size_t instead of u32. [Luca]
>
> Cc: Jani Nikula <jani.nikula at intel.com>
> Signed-off-by: Animesh Manna <animesh.manna at intel.com>
> ---
[...]
> +void intel_dsb_buffer_memset(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size)
> +{
> + if ((idx > dsb_buf->buf_size / 4) || (size > dsb_buf->buf_size - idx * 4))
You actually don't need the first expression. This expression should
enough:
dsb_buf->buf_size <= (idx + size) * sizeof(*dsb_buf->cmd_buf)
> + return;
Blindly returning here doesn't solve the problem, it just hides it. I
think the best would be to use WARN_ON() instead of if.
So:
WARN_ON(dsb_buf->buf_size <= (idx + size) * sizeof(*dsb_buf->cmd_buf));
> +
> + memset(&dsb_buf->cmd_buf[idx], val, size);
> +}
[...]
--
Cheers,
Luca.
More information about the Intel-gfx
mailing list