From 3bf927f03f821461bfc43be38d7e3b8c060a20ff Mon Sep 17 00:00:00 2001 From: Mateo de Mayo <mateo.demayo@collabora.com> Date: Thu, 7 Sep 2023 11:41:15 -0300 Subject: [PATCH] d/na: Reduce relation history lock contention Relation history was being accessed guarded by an external lock in a couple of places. This is redundant since its implementation already defines an internal lock. --- src/xrt/drivers/nreal_air/na_hmd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/xrt/drivers/nreal_air/na_hmd.c b/src/xrt/drivers/nreal_air/na_hmd.c index 868a8661b..1bfedf7fd 100644 --- a/src/xrt/drivers/nreal_air/na_hmd.c +++ b/src/xrt/drivers/nreal_air/na_hmd.c @@ -318,12 +318,10 @@ update_fusion(struct na_hmd *hmd, struct na_parsed_sample *sample, uint64_t time os_mutex_lock(&hmd->device_mutex); update_fusion_locked(hmd, sample, timestamp_ns); - - // We have no tracking, don't return a position. - rel.pose.orientation = hmd->fusion.rot; + rel.pose.orientation = hmd->fusion.rot; // We have no tracking, don't return a position. + os_mutex_unlock(&hmd->device_mutex); m_relation_history_push(hmd->relation_hist, &rel, timestamp_ns); - os_mutex_unlock(&hmd->device_mutex); } static uint32_t @@ -1063,11 +1061,9 @@ na_hmd_get_tracked_pose(struct xrt_device *xdev, U_ZERO(&relation); // Clear out the relation. relation.relation_flags = flags; - os_mutex_lock(&hmd->device_mutex); m_relation_history_get(hmd->relation_hist, at_timestamp_ns, &relation); - os_mutex_unlock(&hmd->device_mutex); - relation.relation_flags = flags; // Needed after history_get + *out_relation = relation; // Make sure that the orientation is valid.