lkml.org 
[lkml]   [2023]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 10/34] media: iris: add PIL functionality for video firmware
From


On 12/18/23 12:32, Dikshita Agarwal wrote:
> Load/unload firmware in memory via mdt loader.
> Firmware loading is part of core initialization
> and unloading is part of core de-initialization.
> This also changes the core states accordingly.
>
> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
> ---
[...]

> +
> +#include "iris_core.h"
> +#include "iris_helpers.h"
> +#include "iris_hfi.h"
> +#include "iris_state.h"
> +
> +static int iris_core_deinit_locked(struct iris_core *core)
I suppose you meant to call this something like _nolock, as
you're calling it with a lock around it

> +{
> + int ret;
> +
> + ret = check_core_lock(core);
> + if (ret)
> + return ret;
> +
> + if (core->state == IRIS_CORE_DEINIT)
> + return 0;
> +
> + iris_hfi_core_deinit(core);
> +
> + iris_change_core_state(core, IRIS_CORE_DEINIT);
You're casually ignoring the return value of the two
above funcs here :/

> +
> + return ret;
> +}
> +
> +int iris_core_deinit(struct iris_core *core)
> +{
> + int ret;
> +
> + mutex_lock(&core->lock);
> + ret = iris_core_deinit_locked(core);
> + mutex_unlock(&core->lock);
> +
> + return ret;
> +}
> +
> +int iris_core_init(struct iris_core *core)
> +{
> + int ret = 0;
> +
> + mutex_lock(&core->lock);
You may be interested in scoped mutexes

> + if (core_in_valid_state(core)) {
> + goto unlock;
> + } else if (core->state == IRIS_CORE_ERROR) {
> + ret = -EINVAL;
> + goto unlock;
> + }
> +
> + if (iris_change_core_state(core, IRIS_CORE_INIT_WAIT)) {
> + iris_change_core_state(core, IRIS_CORE_ERROR);
> + ret = -EINVAL;
> + goto unlock;
> + }
> +
> + ret = iris_hfi_core_init(core);
> + if (ret) {
> + iris_change_core_state(core, IRIS_CORE_ERROR);
> + dev_err(core->dev, "%s: core init failed\n", __func__);
__func__ still seems overly verbose in my eyes

[...]

> +
> +int check_core_lock(struct iris_core *core)
> +{
> + bool fatal = !mutex_is_locked(&core->lock);
> +
> + WARN_ON(fatal);
> +
> + return fatal ? -EINVAL : 0;
You can simply inline this:

if (WARN_ON(!mutex_is_locked(&core->lock))
return -EINVAL;

[...]
> +#define CP_START 0
> +#define CP_SIZE 0x25800000
> +#define CP_NONPIXEL_START 0x01000000
> +#define CP_NONPIXEL_SIZE 0x24800000
> +
> +#define FW_NAME "vpu30_4v.mbn"
This doesn't scale, at all.

Konrad

\
 
 \ /
  Last update: 2023-12-18 22:40    [W:0.352 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site