drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
Extension
.c
Size
30543 bytes
Lines
1138
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct rpc_channel {
	u16 channel_id;
	u32 cookie_high;
	u32 cookie_low;
};

#if IS_ENABLED(CONFIG_DRM_VMWGFX_MKSSTATS)
/* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */
static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] =
{
	{ "vmw_execbuf_ioctl", "vmw_execbuf_ioctl" },
	{ "vmw_cotable_resize", "vmw_cotable_resize" },
};
#endif

/**
 * vmw_open_channel
 *
 * @channel: RPC channel
 * @protocol:
 *
 * Returns: 0 on success
 */
static int vmw_open_channel(struct rpc_channel *channel, unsigned int protocol)
{
	u32 ecx, edx, esi, edi;

	vmware_hypercall6(VMW_PORT_CMD_OPEN_CHANNEL,
			  (protocol | GUESTMSG_FLAG_COOKIE), 0,
			  &ecx, &edx, &esi, &edi);

	if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
		return -EINVAL;

	channel->channel_id  = HIGH_WORD(edx);
	channel->cookie_high = esi;
	channel->cookie_low  = edi;

	return 0;
}



/**
 * vmw_close_channel
 *
 * @channel: RPC channel
 *
 * Returns: 0 on success
 */
static int vmw_close_channel(struct rpc_channel *channel)
{
	u32 ecx;

	vmware_hypercall5(VMW_PORT_CMD_CLOSE_CHANNEL,
			  0, channel->channel_id << 16,
			  channel->cookie_high,
			  channel->cookie_low,
			  &ecx);

	if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
		return -EINVAL;

	return 0;
}

/**
 * vmw_port_hb_out - Send the message payload either through the
 * high-bandwidth port if available, or through the backdoor otherwise.
 * @channel: The rpc channel.
 * @msg: NULL-terminated message.
 * @hb: Whether the high-bandwidth port is available.
 *
 * Return: The port status.
 */
static unsigned long vmw_port_hb_out(struct rpc_channel *channel,
				     const char *msg, bool hb)
{
	u32 ebx, ecx;
	unsigned long msg_len = strlen(msg);

	/* HB port can't access encrypted memory. */
	if (hb && !cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
		vmware_hypercall_hb_out(
			(MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG,
			msg_len,
			channel->channel_id << 16,
			(uintptr_t) msg, channel->cookie_low,
			channel->cookie_high,
			&ebx);

Annotation

Implementation Notes