/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note OR MIT */

/*
 * (C) COPYRIGHT 2023-2024 ARM Limited or its affiliates. All rights reserved.
 */

/*
 * Part of the Mali reference arbiter
 */

#ifndef _MALI_ARBITER_INTERNAL_H_
#define _MALI_ARBITER_INTERNAL_H_

#include <mali_arbiter/mali_arbiter.h>

struct mali_arb;

/**
 * struct mali_arb_priv_data - private Arbiter VM data used to identify and work
 *                             with each VM
 * @entry:    List entry for req_lists.
 * @info:     Public VM data supplied during registration.
 * @arb:      Pointer to the internal Arbiter data.
 * @vm:       Opaque pointer to the private VM data supplied during
 *            registration.
 * @gpu_lost: true if GPU has currently been lost in this VM.
 *
 * Keep track of the information for each VM registered with the arbiter.
 */
struct mali_arb_priv_data {
	struct list_head entry;
	struct mali_vm_data info;
	struct mali_arb *arb;
	struct mali_vm_priv_data *vm;
	bool gpu_lost;
};

/**
 * struct mali_arb_gsi_cb - Callback functions from gpu-subinstance
 * @cb_lock: Callback to acquire gpu-subinstance lock.
 *           arb - arbiter opaque instance.
 *           gsi_idx - gpu-subinstance index.
 * @cb_lock_assert_held: Callback to check if gpu-subinstance lock is acquired.
 *                       arb - arbiter opaque instance.
 *                       gsi_idx - gpu-subinstance index.
 * @cb_unlock: Callback to release gpu-subinstance lock.
 *             arb - arbiter opaque instance.
 *             gsi_idx - gpu-subinstance index.
 * @cb_active: Callback that notices the gpu-subinstance becomes active.
 *             arb - arbiter opaque instance.
 *             gsi_idx - gpu-subinstance index.
 * @cb_idle: Callback that notices the gpu-subinstance becomes idle.
 *           arb - arbiter opaque instance.
 *           gsi_idx - gpu-subinstance index.
 *
 * This struct contains callbacks that gpu-subinstance sub-module will
 * invoke for arbiter-core sub-module.
 */
struct mali_arb_gsi_cb {
	void (*cb_lock)(struct mali_arb *arb, uint32_t gsi_idx);
	void (*cb_lock_assert_held)(struct mali_arb *arb, uint32_t gsi_idx);
	void (*cb_unlock)(struct mali_arb *arb, uint32_t gsi_idx);
	void (*cb_active)(struct mali_arb *arb, uint32_t gsi_idx);
	void (*cb_idle)(struct mali_arb *arb, uint32_t gsi_idx);
};

#endif /* _MALI_ARBITER_INTERNAL_H_ */
