media: venus: Make sys_error flag an atomic bitops
authorStanimir Varbanov <stanimir.varbanov@linaro.org>
Fri, 23 Apr 2021 07:24:54 +0000 (08:24 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 21 Oct 2021 13:20:26 +0000 (14:20 +0100)
Make the sys_error flag an atomic bitops in order to avoid
locking in sys_error readers.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Tested-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/qcom/venus/core.c
drivers/media/platform/qcom/venus/core.h
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/hfi.c
drivers/media/platform/qcom/venus/vdec.c

index de7b32c..0f31cc5 100644 (file)
@@ -65,7 +65,7 @@ static void venus_event_notify(struct venus_core *core, u32 event)
        }
 
        mutex_lock(&core->lock);
-       core->sys_error = true;
+       set_bit(0, &core->sys_error);
        list_for_each_entry(inst, &core->instances, list)
                inst->ops->event_notify(inst, EVT_SESSION_ERROR, NULL);
        mutex_unlock(&core->lock);
@@ -161,7 +161,7 @@ static void venus_sys_error_handler(struct work_struct *work)
        dev_warn(core->dev, "system error has occurred (recovered)\n");
 
        mutex_lock(&core->lock);
-       core->sys_error = false;
+       clear_bit(0, &core->sys_error);
        mutex_unlock(&core->lock);
 }
 
index a3f077f..46d87a1 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef __VENUS_CORE_H_
 #define __VENUS_CORE_H_
 
+#include <linux/bitops.h>
 #include <linux/list.h>
 #include <media/videobuf2-v4l2.h>
 #include <media/v4l2-ctrls.h>
@@ -182,7 +183,7 @@ struct venus_core {
        unsigned int state;
        struct completion done;
        unsigned int error;
-       bool sys_error;
+       unsigned long sys_error;
        const struct hfi_core_ops *core_ops;
        const struct venus_pm_ops *pm_ops;
        struct mutex pm_lock;
index 7f2f5b9..8cebb8e 100644 (file)
@@ -1486,7 +1486,7 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q)
                ret |= venus_helper_intbufs_free(inst);
                ret |= hfi_session_deinit(inst);
 
-               if (inst->session_error || core->sys_error)
+               if (inst->session_error || test_bit(0, &core->sys_error))
                        ret = -EIO;
 
                if (ret)
index 0f24823..179b1f8 100644 (file)
@@ -214,7 +214,7 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt)
         * session_init() can't pass successfully
         */
        mutex_lock(&core->lock);
-       if (!core->ops || core->sys_error) {
+       if (!core->ops || test_bit(0, &inst->core->sys_error)) {
                mutex_unlock(&core->lock);
                return -EIO;
        }
index 41c5a35..11990a9 100644 (file)
@@ -1231,7 +1231,7 @@ static void vdec_session_release(struct venus_inst *inst)
        ret = hfi_session_deinit(inst);
        abort = (ret && ret != -EINVAL) ? 1 : 0;
 
-       if (inst->session_error || core->sys_error)
+       if (inst->session_error || test_bit(0, &core->sys_error))
                abort = 1;
 
        if (abort)