// SPDX-License-Identifier: GPL-2.0 OR MIT /************************************************************************** * * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. *
**************************************************************************/ #include"vmwgfx_bo.h" #include"vmwgfx_drv.h" #include"vmwgfx_devcaps.h"
mutex_init(&fifo->fifo_mutex);
init_rwsem(&fifo->rwsem);
min = 4; if (dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO)
min = vmw_read(dev_priv, SVGA_REG_MEM_REGS);
min <<= 2;
/* * Reserve @bytes number of bytes in the fifo. * * This function will return NULL (error) on two conditions: * If it timeouts waiting for fifo space, or if @bytes is larger than the * available fifo space. * * Returns: * Pointer to the fifo, or null on error (possible hardware hang).
*/ staticvoid *vmw_local_fifo_reserve(struct vmw_private *dev_priv,
uint32_t bytes)
{ struct vmw_fifo_state *fifo_state = dev_priv->fifo;
u32 *fifo_mem = dev_priv->fifo_mem;
uint32_t max;
uint32_t min;
uint32_t next_cmd;
uint32_t reserveable = fifo_state->capabilities & SVGA_FIFO_CAP_RESERVE; int ret;
mutex_lock(&fifo_state->fifo_mutex);
max = vmw_fifo_mem_read(dev_priv, SVGA_FIFO_MAX);
min = vmw_fifo_mem_read(dev_priv, SVGA_FIFO_MIN);
next_cmd = vmw_fifo_mem_read(dev_priv, SVGA_FIFO_NEXT_CMD);
if (dev_priv->cman)
ret = vmw_cmdbuf_reserve(dev_priv->cman, bytes,
ctx_id, false, NULL); elseif (ctx_id == SVGA3D_INVALID_ID)
ret = vmw_local_fifo_reserve(dev_priv, bytes); else {
WARN(1, "Command buffer has not been allocated.\n");
ret = NULL;
} if (IS_ERR_OR_NULL(ret)) return NULL;
/** * vmw_cmd_commit_flush - Commit fifo space and flush any buffered commands. * * @dev_priv: Pointer to device private structure. * @bytes: Number of bytes to commit.
*/ void vmw_cmd_commit_flush(struct vmw_private *dev_priv, uint32_t bytes)
{ if (dev_priv->cman)
vmw_cmdbuf_commit(dev_priv->cman, bytes, NULL, true); else
vmw_local_fifo_commit(dev_priv, bytes);
}
/** * vmw_cmd_flush - Flush any buffered commands and make sure command processing * starts. * * @dev_priv: Pointer to device private structure. * @interruptible: Whether to wait interruptible if function needs to sleep.
*/ int vmw_cmd_flush(struct vmw_private *dev_priv, bool interruptible)
{
might_sleep();
if (dev_priv->cman) return vmw_cmdbuf_cur_flush(dev_priv->cman, interruptible); else return 0;
}
int vmw_cmd_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
{ struct svga_fifo_cmd_fence *cmd_fence;
u32 *fm; int ret = 0;
uint32_t bytes = sizeof(u32) + sizeof(*cmd_fence);
fm = VMW_CMD_RESERVE(dev_priv, bytes); if (unlikely(fm == NULL)) {
*seqno = atomic_read(&dev_priv->marker_seq);
ret = -ENOMEM;
(void)vmw_fallback_wait(dev_priv, false, true, *seqno, false, 3*HZ); goto out_err;
}
do {
*seqno = atomic_add_return(1, &dev_priv->marker_seq);
} while (*seqno == 0);
if (!vmw_has_fences(dev_priv)) {
/* * Don't request hardware to send a fence. The * waiting code in vmwgfx_irq.c will emulate this.
*/
/** * vmw_cmd_emit_dummy_legacy_query - emits a dummy query to the fifo using * legacy query commands. * * @dev_priv: The device private structure. * @cid: The hardware context id used for the query. * * See the vmw_cmd_emit_dummy_query documentation.
*/ staticint vmw_cmd_emit_dummy_legacy_query(struct vmw_private *dev_priv,
uint32_t cid)
{ /* * A query wait without a preceding query end will * actually finish all queries for this cid * without writing to the query result structure.
*/
/** * vmw_cmd_emit_dummy_gb_query - emits a dummy query to the fifo using * guest-backed resource query commands. * * @dev_priv: The device private structure. * @cid: The hardware context id used for the query. * * See the vmw_cmd_emit_dummy_query documentation.
*/ staticint vmw_cmd_emit_dummy_gb_query(struct vmw_private *dev_priv,
uint32_t cid)
{ /* * A query wait without a preceding query end will * actually finish all queries for this cid * without writing to the query result structure.
*/
/** * vmw_cmd_emit_dummy_query - emits a dummy query to the fifo using * appropriate resource query commands. * * @dev_priv: The device private structure. * @cid: The hardware context id used for the query. * * This function is used to emit a dummy occlusion query with * no primitives rendered between query begin and query end. * It's used to provide a query barrier, in order to know that when * this query is finished, all preceding queries are also finished. * * A Query results structure should have been initialized at the start * of the dev_priv->dummy_query_bo buffer object. And that buffer object * must also be either reserved or pinned when this function is called. * * Returns -ENOMEM on failure to reserve fifo space.
*/ int vmw_cmd_emit_dummy_query(struct vmw_private *dev_priv,
uint32_t cid)
{ if (dev_priv->has_mob) return vmw_cmd_emit_dummy_gb_query(dev_priv, cid);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.